Alternates to url arguments ($_GET)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Alternates to url arguments ($_GET)

Post by nickvd »

I remember reading a thread, or an article about getting rid of url parameters in the standard form: page.php?foo=bar

with something like: page.php/foo/bar

However, after much searching on google, i've come up empty handed. If anyone has the page in question bookmarked, i surely could use it :)

On to the real reason why i'm doing it this way. I'm writing a quick breadcrumbs class (more heavily modifying than writing) and most of my pages use the ?page=articles&id=3 scheme... This will obviously not work, since the page is always index.php... however, using the page.php/page/articles/id/3 or even just page.php/articles/3 would let me use the bread crumbs w/o having to have an array of all pages/subpages...
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Okay, I don't exactly have the answer to your question, but I have two comments that are based on my experience:

1. This type of "Paging" isn't available to all PHP/Webserver combos, so don't count on being able to do it.

2. Because you seem to have a clearly defined hierarchy for your GET lables, why not do the necessary breadcrumb juggling yourself? First you define the list of GET values:

Code: Select all

$LIST_GET_TREEї] = 'article';
$LIST_GET_TREEї] = 'id';
The closer to zero, the closer to the root of the tree, so to speak. You can do some things, like:

Code: Select all

$tree_size = size();
for($i = 0; $i < $tree_size; $i++) {
  // clean() is a user defined func that you use to filter parameters, like restrict to integers or whatnot.
  if (isset($_GETї$tree_sizeї$i]]) AND clean($_GETї$tree_sizeї$i]], $tree_sizeї$i])) {
    break;
  } else {
    $LIST_PARAMETERSї] = $_GETї$tree_sizeї$i]]
  }
}
I'm interested. What premade class are you using for breadcrumbing?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

the keywords needed for a websearch is "url rewriting" and then everything becomes clear :)
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

Code: Select all

$args = explode ('/', $_SERVER['PATH_INFO']);
$args will then contain the splitted arguments (what I call them :P )

http://se.php.net/manual/en/reserved.va ... les.server
Post Reply