PHP URL Parent Directory
From w3cyberlearnings
Contents |
PHP URL and Parent Directory
You want to call/access the filea.php in Directory2 by the file2.php in Directory1. This is mean, file2.php needs to call filea.php at the same directory level.
- ParentDirectory
- Directory1
- file1.php
- file2.php
- Directory2
- filea.php
- Directory1
in Directory1/file1.php
<?php echo direname(___FILE___); ?>
Output
/ParentDirectory/Directory1
Get Parent Directory
<?php echo dirname(direname(___FILE___)); ?>
Output
/ParentDirectory/
Call filea.php file from Directory1/file1.php
In file1.php needs to access filea.php
<?php echo dirname(direname(___FILE___))."/Directory2/filea.php; ?>
Related Links
Manage URL
- PHP CURRENT URL
- PHP CURRENT HOST
- PHP URL Parameters
- PHP URL PROTOCOL
- PHP URL Script Name
- PHP FULL URL
- PHP URL Parent Directory