Forum Moderators: coopster

Message Too Old, No Replies

How to do correct path system with PHP?

         

toplisek

9:20 am on Aug 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Path is defined as $_PATHROOT=$_SERVER['DOCUMENT_ROOT']."/";
Within files are links to other sections of website. So, path should work on all links regardless of folder location for the particular files.

I have used PHP code for the path to include file like:
[PHP]
<?PHP @require_once($_PATHROOT."en-US/bottompart/bottom.php");?>
[/PHP]

Issues is the following:
If I use
[PHP]
<?PHP @require_once($_PATHROOT."bottompart/bottom.php");?>
[/PHP]
it will not work work when I add alsoat the top of each file path variables (like file bottom.php)
[PHP]
<?PHP
@require_once("../variables/pathvariables.php");
?>
[/PHP]

Questions:

1. Why ../variables/ should be removed in case of $_PATHROOT=$_SERVER['DOCUMENT_ROOT']."/";
2. Is not needed code at the top of each INCLUDED file that links will work within pages?

jatar_k

2:29 pm on Aug 6, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I am not quite getting what is happening, are getting an error when you try to require? if so what is it?

you might want to remove the @ symbols to allow errors to show, it may give you more info.