Home > Backend Development > PHP Tutorial > Interpret PHP realpath path function for you_PHP tutorial

Interpret PHP realpath path function for you_PHP tutorial

WBOY
Release: 2016-07-15 13:32:12
Original
1035 people have browsed it

PHP realpath path function will detect whether the target file (or folder) pointed to by $path actually exists, which is equivalent to calling file_exists($path).

If the target file exists and is not a symbolic link (called "shortcut" in Windows), the absolute path name of the file is returned and does not contain '/./' or '/../'.
If the target file is a symbolic link or does not exist, realpath() returns FALSE.

var_dump( realpath('./test.php') );

//If the test.php file can be found in the ./ path, the output result will be:

string 'E:DropboxMy Dropboxcodephptest.php' (length=48)

//If test.php is found under the ./ path and is a symbolic link, the output result is:

boolean false

//If the test.php file cannot be found under the ./ path, the output result is:

boolean false

//If it is executed under the Windows platform , the execution result of the following code is the same as above, because in Windows, both slash (/) and backslash () can be used as directory separators.

var_dump( realpath('.test.php') );

I hope the knowledge about the PHP realpath path function introduced above can be helpful to everyone.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446153.htmlTechArticlePHP realpath path function will detect whether the target file (or folder) pointed to by $path actually exists, which is equivalent to calling file_exists($path). If the target file exists and is not a symbolic link...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template