In PHP, you can use the realpath() function to convert a relative path to an absolute path. The function of this function is to return the absolute path. This function will delete all symbolic connections and return the absolute path name. If it fails, it will return The result is FALSE and the syntax is "realpath (relative path)".
The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer
realpath() function returns the absolute path.
This function removes all symbolic links (such as '/./', '/../' and redundant '/') and returns the absolute path name.
If it fails, this function returns FALSE.
Syntax
realpath(path)
path Required. Specifies the path to be checked.
The example is as follows:
Output result:
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to convert relative path to absolute path in php. For more information, please follow other related articles on the PHP Chinese website!