...

View Full Version : What am I looking for ??



mOrloff
02-02-2010, 10:11 PM
If a PHP site uses a URI like www.example.com/?target, how is that done?

Back when I started looking into OO PHP, I came across a good video tute series on this specifically, but now that I'm actually looking for it, I'm not finding it. :rolleyes:

Can someone please feed me some keywords or links ?

~ Mo

mlseim
02-02-2010, 10:34 PM
http://www.google.com/search?q=php+passing+variable+in+URL&btnG=Search

mOrloff
02-02-2010, 10:52 PM
Thanks.
I think I need to clarify :)
(I'm already comfortable with GET)

The target (if memory serves correctly) was the name of a class, and that was how the website is browsed.
Instead of having seperate page for the "contact" and "about us" info, it would be
www.example.com/?contact
and
www.example.com/?aboutUs
respectively.

~ Mo

Jacobb123
02-02-2010, 10:58 PM
This is called passing a variable via $_GET method.

What happens is that the link may go to index.php?page=aboutus

Inside the index.php there is an if statement that say that if $_GET['page']==aboutus then show about us content.

That's the very watered down version.

mOrloff
02-02-2010, 11:05 PM
Oh, your kidding !! :D
That's so nice and simple.
I thought it was something more involved :o

Thanks.

masterofollies
02-02-2010, 11:07 PM
I believe this is what you are looking for.


if (isset($_GET["do"])) {
$do = explode(":",$_GET["do"]);

switch($do[0])
{
case 'main':
main();
break;

}
}

Makes this: www.example.com/page.php?do=main

mOrloff
02-02-2010, 11:16 PM
Thanks.

And, what if I didn't want to display the page name (like found at www.awesomephp.com (http://www.awesomephp.com/?a=home))?

Len Whistler
02-02-2010, 11:39 PM
Thanks.

And, what if I didn't want to display the page name (like found at www.awesomephp.com (http://www.awesomephp.com/?a=home))?

That page displays the page name, I prefer to make the GET url descriptive - and bookmarkable, like:


index.php?page=about_us
index.php?page=products
index.php?page=contact_us
index.php?forum=4&topic=45789


Not urls with single letters, like:


index.php?p=products
index.php?a=56889




--------------

JAY6390
02-03-2010, 02:08 AM
To be honest it's much nicer to have clean URI's using some simple htaccess rewrite rules and some clever coding to load pages up. Something like
www.example.com (http://www.example.com)/page/about
looks much nicer than
www.example.com (http://www.example.com)/?page=about
in my opinion

MattF
02-03-2010, 02:57 AM
To be honest it's much nicer to have clean URI's using some simple htaccess rewrite rules and some clever coding to load pages up. Something like
www.example.com (http://www.example.com)/page/about
looks much nicer than
www.example.com (http://www.example.com)/?page=about
in my opinion

You could also achieve the same outside of using rewrite by using an error handler which loads the requested page content.

Edit: Why are there always so many methods of achieving the same end? :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum