Php function argument error suppression, empty() isset() emulation

后端 未结 14 719
执笔经年
执笔经年 2021-01-11 17:32

I\'m pretty sure the answer to this question is no, but in case there\'s some PHP guru

is it possible to write a function in a way where invalid arguments or non exi

14条回答
  •  滥情空心
    2021-01-11 18:17

    If you simply add a default value to the parameter, you can skip it when calling the function. For example:

    function empty($paramName = ""){
        if(isset($paramName){
            //Code here
        }
        else if(empty($paramName)){
            //Code here
        }
    }
    

提交回复
热议问题