AeonE Posted March 23, 2006 Share Posted March 23, 2006 guys, I'have some question to ask[quote]eCom | - eCom.php | | -Admin | |- Admin.php | |- User | |- User.php[/quote]where eCom is my TOP directory and Admin/user is a folder under eCom directory,here's my question, how do I link those 3 together without repeating the hyperlink code? assuming in eCom.php I have created a hyperlink to Admin like this <?php echo "<a href=\"Admin/Admin.php>Admin Page</a>" ?> and of course my Home is <?php echo "<a href=\"eCom.php>Home</a>" ?>so it looks like this in eCom.php,[quote]<?php echo "<a href=\"eCom.php>Home</a>" ?><?php echo "<a href=\"Admin/Admin.php>Admin Page</a>" ?><?php echo "<a href=\"User/User.php>User</a>" ?>[/quote]and for Admin.php,[quote]<?php echo "<a href=\"../eCom.php>Home</a>" ?><?php echo "<a href=\"Admin.php>Admin Page</a>" ?><?php echo "<a href=\"../User/User.php>User</a>" ?>[/quote]it works to link them together but...I want a simple method that allows you to only need to define SERVER root to access files in that root, how you do that? meaning that I can remove this: [quote]<?php echo "<a href=\"../eCom.php>Home</a>" ?><?php echo "<a href=\"Admin.php>Admin Page</a>" ?><?php echo "<a href=\"../User/User.php>User</a>" ?>[/quote]for my admin.php , and only add include ('../eCom.php'); inside my Admin.phpwhat should I write in my eCom.php , please help!!!many thanks Link to comment https://forums.phpfreaks.com/topic/5591-how-to-define-the-server-root/ Share on other sites More sharing options...
craygo Posted March 23, 2006 Share Posted March 23, 2006 you can always make a file say configs.php. And in the file you can set up your pages[code]$ecom = "http://ecom.com/ecom.php";$admin = "http://ecom.com/admin/admin.php";$users = "http://ecom.com/users/user.php";[/code]then on the top of each page you can just put in[code]require('configs.php');[/code]Then you can reference each page with the variable[code]<?php echo "<a href=\"$ecom\">Home</a>" ?><?php echo "<a href=\"$admin\">Admin Page</a>" ?><?php echo "<a href=\"$users\">User</a>" ?>[/code]And if you need to add some parameters to it then you can do it like this[code]<?php echo "<a href=\"$ecom\">Home</a>" ?><?php echo "<a href=\"$admin\">Admin Page</a>" ?><?php echo "<a href=\"$users?id=2\">User</a>" ?>[/code]There are other ways to get the document root but you would still have to enter in the folders after the root.Ray Link to comment https://forums.phpfreaks.com/topic/5591-how-to-define-the-server-root/#findComment-19943 Share on other sites More sharing options...
AeonE Posted March 23, 2006 Author Share Posted March 23, 2006 yeahhhh man it works,thx alot Link to comment https://forums.phpfreaks.com/topic/5591-how-to-define-the-server-root/#findComment-20037 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.