If I have the following statement:
$b = empty($a) ? "null" : "'$a'"
To avoid copy and paste, I would like to add it to a function:
function x($a) { return empty($a) ? "null" : "'$a'" }
So, I can do:
$b = x($a); // $a is not defined, so PHP complains $d = x($c); // same with $c
But then I would get an error from PHP because $a not defined. Is there any way to do this except using the @ operator?
EDIT: I mean the error that occurs when x () is called, and not inside x (). You know, you can do isset () and empty () on everything that is not defined, and PHP will never complain. But if you call the function with something undefined, PHP will complain. What is the problem.
source share