My directory listing is: Users>Images>PreDefines
Where i am creating a php file ie index.php
in PreDefines Folder. I want to include a php file from Users Folder ie include('header.php');
. But There is a problem. header.php
file contain include('title.php');
which not coming in PreDefines>index.php
what should i do to include a file from another directory which includes others php files also.
you can simply navigate with ../
which means go backward one step and then go wherever you want
Assuming you are in Users/Images/Predefines/index.php and you want to include a file in Users you say include('../../header.php');
Or for example you have another folder in users called assets which has a file index.php. You do: include('../../assets/index.php);
Always include in absolute to the directory you are working on. Something that might help php has getcwd()
which returns the current working directory. Also if you are going to change the server such as from windows to linux or other type of servers instead of /
use the DIRECTORY_SEPARATOR
constant which will place a separator according to your server for example
include('..'.DIRECTORY_SEPARATOR.'title.php')
Hope i understood your question
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.