How to convert relative path to absolute path in php

WBOY
Release: 2023-03-15 17:42:01
Original
3021 people have browsed it

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)
Copy after login

path Required. Specifies the path to be checked.

The example is as follows:

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

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!

Related labels:
php
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