Open In App

PHP | stream_is_local() Function

Last Updated : 17 Dec, 2018
Comments
Improve
Suggest changes
Like Article
Like
Report
The stream_is_local() function is an inbuilt function in PHP which is used to check if a stream is a local stream or URL. Syntax:
bool stream_is_local( $stream )
Parameters: This function accepts single parameter $stream, which is used to specify the stream to be check. Return Value: This function returns True on success or False on failure. Below programs illustrate the stream_is_local() function in PHP: Program 1: PHP
<?php

// PHP program to illustrate
// stream_is_local function
$strm = "https://www.geeksforgeeks.org";

$res = stream_is_local($strm);

// Print result
var_dump($res);
?>
Output:
bool(false)
Program 2: Program to print the length of array return by the function. php
<?php

// PHP program to illustrate 
// stream_is_local function
$stream1 = '/geeks.jpg'; // local
$stream2 = 'file://geeks.jpg'; // local
$stream3 = 'http://geeksforgeeks.org'; // non local stream

// Checking all strings and print result
$local = stream_is_local($stream1);
var_dump($local);

$shouldbelocal = stream_is_local($stream2);
var_dump($shouldbelocal);

$remote = stream_is_local($stream3);
var_dump($remote);
?>
Output:
bool(true)
bool(false)
bool(false)
Reference: http://php.net/manual/en/function.stream-is-local.php

Next Article

Similar Reads