Current Location: Home> Function Categories> stream_resolve_include_path

stream_resolve_include_path

Resolve file name according to include path
Name:stream_resolve_include_path
Category:Stream
Programming Language:php
One-line Description:Resolves the relative path to an absolute path and searches the directory specified in include_path to find files

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:

  • $filename: The file path to parse can be a relative or an absolute path.

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:

  • /var/www/html/index.php
  • /var/www/includes/library.php
 // 示例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

Similar Functions
Popular Articles