I have a URL which i pass parameters into
example/success.php?id=link1
I use php to grab it
$slide = ($_GET["id"]);
then an if statement to display content based on parameter
<?php if($slide == 'link1') { ?>
//content
} ?>
Just need to know in PHP how to say, if the url param exists grab it and do the if function, if it doesn't exist do nothing.
Thanks Guys
It is not quite clear what function you are talking about and if you need 2 separate branches or one. Assuming one:
Change your first line to
Use isset()
EDIT: This is added for the completeness sake. $_GET in php is a reserved variable that is an associative array. Hence, you could also make use of 'array_key_exists(mixed $key, array $array)'. It will return a boolean that the key is found or not. So, the following also will be okay.
Why not just simplify it to if($_GET['id']). It will return true or false depending on status of the parameter's existence.
Here is the PHP code to check if 'id' parameter exists in the URL or not:
I hope it will help you.
You want something like that