Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Directory Listing/Relative URL

Status
Not open for further replies.

KooLTaB101

Technical User
Mar 21, 2003
8
US
Hi,

I am trying to create a line item at the top of my page that is dynamic in that it tells users where they are in relation to the home page. For example, if they are at the homepage, the line would say "Home/" and if they were in a folder "Directory 2", it would say "Home/ Directory 2/." Also, they should be hyperlinks so they can get to "Home" rather quickly by simply clicking on it. I have each of my pages call a specific page using the require call tag. The line item would be in that one specific page...but if need be, I could probably make due of the line item could be on each specific page. Let me try to give some examples:

Home
index.php
page1.php
/Directory 2
page2.php

So that if Home/Directory 2/page2.php was called, it would export that in the line item.

Also, the require tag calls index1.php in the following way: <? require 'index1.php'; ?>

I hope all this makes sense as in what I am trying to do. If need be, I can give more examples to clear it up.

Thanks,
Matt
 
It's not too hard.

$_SERVER['PHP_SELF'] contains the path, relative to the web site's document root, of the script invoked by the web server.

All you have to do is split that value at whatever is the correct file/directory separator for your operating system, then wrap the pieces in <a>...</a> tags. Want the best answers? Ask the best questions: TANSTAAFL!
 
I am still a little rusty at php. Could you give me a complete code?

Thanks for the help,
Matt
 
No. By policy, I only post code when my answer would be less clear without it. Depending on your typographical style of editing source code, this will only be a 3 to 5 line script.

$_SERVER is documented here:
split() is documented here:
since split() returns an array, you might be interested in foreach(): Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top