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

php-file path problem

WBOY
Release: 2016-07-30 13:31:25
Original
1292 people have browsed it

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

(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;
Copy after login

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.

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