Home  >  Article  >  Backend Development  >  How to convert relative path to absolute path in php

How to convert relative path to absolute path in php

WBOY
WBOYOriginal
2022-04-13 10:49:443007browse

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)".

How to convert relative path to absolute path in php

The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer

How to convert relative path to absolute path in php

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:

<?php
echo realpath("1118.02.png");
?>

Output result:

How to convert relative path to absolute path in php

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!

Statement:
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