Example 1 — Compare a File Path and an HTTP URL
Print whether a local path and a remote URL are considered local.
<?php
echo "file path: ", stream_is_local(__FILE__) ? "yes" : "no", PHP_EOL;
echo "http url: ", stream_is_local("http://example.com/a.txt") ? "yes" : "no", PHP_EOL; How It Works
- __FILE__ is the path of the current script on disk.
- stream_is_local() returns true for that local path.
- An http:// URL uses a remote wrapper, so the result is false.
- The demo prints yes and no without opening any network connection.

