Home >Backend Development >PHP Tutorial >php-file path problem

php-file path problem

WBOY
WBOYOriginal
2016-07-30 13:31:251294browse

1. Background

Today when I was developing a sample website, I encountered a troublesome thing, which was the file path problem of Php. I was very confused. I finally gained some knowledge by checking relevant information!

2. The specific examples are as follows

(1) The URL address of this test is as follows: getallifo.php file under the app folder

http://localhost:8081/GoodsServers/app/getAllIfo.php

(2) Test results

$pa= $_SERVER['DOCUMENT_ROOT']; 
echo $pa;  # D:/Wamp/wamp/www/
echo '<br>';
echo __FILE__; # D:\Wamp\wamp\www\GoodsServers\app\getAllIfo.php
echo '<br>';
echo dirname(__FILE__); # D:\Wamp\wamp\www\GoodsServers\app
echo '<br>';
echo dirname(dirname(__FILE__)); # D:\Wamp\wamp\www\GoodsServers
echo '<br>';
echo basename(__FILE__); # getAllIfo.php
Exit;

Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The above has introduced the php-file path problem, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

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