Fast Loans - Free Ringtone - cPanel Hosting - World websites - Share Prices

PDA

View Full Version : Using the Case statement for Meta Descriptions


aaron_nimocks
Jun 8th 2007, 11:00 am
I have a 50 page site that uses PHP. Im looking at making meta descriptions for each page. Now the easiest way I can think of is using cases.

Now Im looking at just doing cases based on the URL. So the depending on the URL I can enter a varialble for the meta description.

Heres the basic idea but it dont work.


<?php
switch ($_SERVER["PHP_SELF"])
{
case "/page1":
$description = "page 1 description";
break;
case "/page2":
$description = "page 2 description";
break;
case "/page3":
$description = "page 3 description";
break;
}
?>

Could anyone help me complete my idea. Im a little confused on what to use for the switch.

Thanks

nico_swd
Jun 8th 2007, 11:03 am
$_SERVER["PHP_SELF"] referrers to the filename, and not the request URI.

it should look more of less like:

<?php
switch (basename($_SERVER["PHP_SELF"]))
{
case "page1.php":
$description = "page 1 description";
break;
case "page2.php":
$description = "page 2 description";
break;
case "page3.php":
$description = "page 3 description";
break;
}
?>


Just echo $_SERVER["PHP_SELF"] and you'll see what you get, and what you need as case.

aaron_nimocks
Jun 8th 2007, 11:07 am
Thanks will give it a shot real quick.