Entrepreneur
BANNED
- Oct 12, 2007
- 439
- 391
I'm building a page and for tracking purposes I'm trying to use switch to create a variable which is a link ($link) that can then be shown throughout the page, by echoing this new variable.
What i need to do is, check the url, (is this index or other) and if index it displays one URL everywhere $link appears, and using the switch default, i'll display another link for all other pages.
The code below worked until i decided to use it as a variable.
Please help my lovely Blackhat Friends. Oh, and the error is in line 2, so probably something to do with me trying to assign the output to a variable?
btw, $val is the page and my php knowledge is very low!
Thanks
What i need to do is, check the url, (is this index or other) and if index it displays one URL everywhere $link appears, and using the switch default, i'll display another link for all other pages.
The code below worked until i decided to use it as a variable.
Please help my lovely Blackhat Friends. Oh, and the error is in line 2, so probably something to do with me trying to assign the output to a variable?
btw, $val is the page and my php knowledge is very low!
Code:
<?php
$link = switch ($val) {
case "index":
echo "http://buy.php";
break;
default:
echo "http://optin.php";
}
?>
Thanks