johnsmith153 Posted November 26, 2010 Share Posted November 26, 2010 The below of course doesn't work as NULL and blank are the same. How could I get somethig like this to work? function getValue($val) { switch ($val) { case NULL: echo ""; break; case ""; echo $_GET['value']; break; default: echo $val; break; } } //this uses current value in $_GET['value'] (don't provide a new one) getValue(); //this uses the new value provided getValue("hello"); //this clears and displays nothing getValue(NULL); Link to comment https://forums.phpfreaks.com/topic/219920-null-are-all-the-same/ Share on other sites More sharing options...
johnsmith153 Posted November 26, 2010 Author Share Posted November 26, 2010 Ensure you use this //this uses current value in $_GET['value'] (don't provide a new one) getValue(""); ...and use is_null instead of ==NULL Link to comment https://forums.phpfreaks.com/topic/219920-null-are-all-the-same/#findComment-1140004 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.