In PHP, I have a webpage: http://www.example.com/index.php?param=val¶m2=val2&so_on=so_on
.
How can I get param
's value and put it in $variable
only if the parameter is defined in the URL? Otherwise, I want to set $variable
to a default value like 123456789
. Is this possible? Thanks!
Just use a ternary and it will always be set as you asked
$var = (isset($_GET['param'])) ? $_GET['param'] : '123456789';