Why don't we have two nulls?

后端 未结 27 1759
孤独总比滥情好
孤独总比滥情好 2021-02-02 08:38

I\'ve often wondered why languages with a null representing \"no value\" don\'t differentiate between the passive \"I don\'t know what the value is\"

27条回答
  •  没有蜡笔的小新
    2021-02-02 08:47

    Within PHP Strict you need to do an isset() check for set variables (or else it throws a warning)

    if(!isset($apple))
    {
        askForApple();
    }
    
    if(isset($apple) && empty($apple))
    {
        sulk();
    }
    else
    {
        eatApple();
    }
    

提交回复
热议问题