I have the following PHP script
<?php
echo (($statusSet) == 'all') ? "class='selected'": "";
?>
What I would like to do is include an OR into this to say where $statusSet is equal to all OR NULL
Im competely lost with hwo to write this as I tried adding the normal type of OR statement which didnt work
<?php
echo ((($statusSet) == 'all')||(($statusSet) == 'all'))) ? "class='selected'": "";
?>
All you’re doing is adding another expression to be evaluated in the overall if statement.
Someone below posted a nearly-identical snippet to mine, but used is_null() instead. Note that using is_null() or === null is fine, but using == null isn’t best practices – it won’t ensure type equality so if $statusSet was set to (int)0, doing $statusSet == null would return true when it’s actually not a null value.