I'm trying to have my includes in one directory and be able to link to them from anywhere, any directory level. I found these two methods to accomplish the task, I think, but I don't really understand them that well. Can someone explain?
http://us3.php.net/ini_set
http://www.php.net/m...nclude-path.php
includes
Started by Frantic, Aug 19 2006 02:37 PM
2 replies to this topic
#1
Posted 19 August 2006 - 02:37 PM
|
|
|
#2
Posted 21 August 2006 - 12:54 PM
... Yes, can someone explain?
#3
Posted 27 August 2006 - 09:31 PM
i didnt look at the links because im too lazy, but ill explain what you're trying to do.
the main thing you need to know is where the files are located in ralation to eachother; say your directory structure looks like this:
the main thing you need to know is where the files are located in ralation to eachother; say your directory structure looks like this:
>Directory
->includes
-->lang.php
-->config.php
->admin
-->folder2
---> file1.php
-->admin.php
->index.php
->mainfile.php
Lets first assume you are working with mainfile.php and you want to include config.php you would do:include('includes/config.php');
Now lets assume you are working with admin.php and want to include config.php you would have to use the .. (two dots) for example include('../includes/config.php'); which basically tells php to "go back one directory and then navigate to the includes directory then include the config.php file.' Lastly lets say you are working with file1.php you would have to use 2 sets of .. (two dots) telling php to 'go back two directorys then navigate to the includes directory and include config.php' include('../../includes/config.php');
i think thats what you're trying to do


Sign In
Create Account


Back to top









