Current Location: Home> Function Categories> stream_is_local

stream_is_local

Check if the stream is a local stream
Name:stream_is_local
Category:Stream
Programming Language:php
One-line Description:Determine whether the given stream is a local file stream

Function name: stream_is_local()

Applicable version: PHP 5 >= 5.2.4, PHP 7

Function description: The stream_is_local() function is used to determine whether the given stream is a local file stream.

usage:

 bool stream_is_local ( mixed $stream )

parameter:

  • $stream: The stream to be checked. It can be a resource type stream or a string containing the flow path.

Return value:

  • Returns true if the given stream is a local file stream, otherwise returns false.

Example:

 // 示例1:检查本地文件流$stream = fopen('example.txt', 'r'); if (stream_is_local($stream)) { echo '该流是本地文件流'; } else { echo '该流不是本地文件流'; } fclose($stream); // 示例2:检查文件路径是否为本地文件流$filePath = 'example.txt'; if (stream_is_local($filePath)) { echo '该文件路径是本地文件流'; } else { echo '该文件路径不是本地文件流'; }

Notes:

  • This function is only suitable for checking whether a file stream is a local file stream, and is not suitable for checking for other types of streams.
  • Before using this function, make sure that the stream has been opened, or a valid file path is passed as a parameter.
  • If the given stream is not a valid file stream or file path, the function returns false.
Similar Functions
Popular Articles