Jump to content

NULL ! "" are all the same


johnsmith153

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.