Jump to: navigation, search

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

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
  1. PHP CURRENT URL
  2. PHP CURRENT HOST
  3. PHP URL Parameters
  4. PHP URL PROTOCOL
  5. PHP URL Script Name
  6. PHP FULL URL
  7. PHP URL Parent Directory
Navigation
Web
SQL
MISC
References