Possible Duplicate:
Where can I read about conditionals done with ? and :
I want do the following without using if else or a ternary operator:
if $_GET['a'] is not null then set $a= $_GET['a'] else set its value to "default".
I tried $a= $_GET['a'] || "default". but it doesnt work.
I remember seeing something like this in a code sample, but I can’t recall now.
I think a ternary if is your best bet here.
In this case I would use isset check – to determine if the key is set and is not null:
The or operator
||doesn’t work to null coalesce like that in PHP, but you might have seen it in JavaScript where it can be used to set a value to the first non-false result:e.g