stream_resolve_include_path
Resolve file name according to include path
Function name: stream_resolve_include_path()
Applicable version: PHP 5 >= 5.3.2
Function description: stream_resolve_include_path() The function resolves the relative path to an absolute path and searches the directory specified in include_path to find the file.
Usage: string stream_resolve_include_path ( string $filename )
parameter:
Return value: If a file is found, the absolute path to the file is returned; if no file is found, false is returned.
Example: Suppose we have the following directory structure:
// 示例1:使用相对路径$filename = '../includes/library.php'; $absolutePath = stream_resolve_include_path($filename); if ($absolutePath !== false) { echo "文件的绝对路径为:$absolutePath"; } else { echo "文件未找到"; } // 示例2:使用绝对路径$filename = '/var/www/includes/library.php'; $absolutePath = stream_resolve_include_path($filename); if ($absolutePath !== false) { echo "文件的绝对路径为:$absolutePath"; } else { echo "文件未找到"; }
Output result: Example 1: The absolute path of the file is: /var/www/includes/library.php Example 2: The absolute path of the file is: /var/www/includes/library.php