3 ms·
so what is wrong with; if(function_exists(custom_func) { $x = @custom_func(); } if((!isset($x)) || (empty($x))) { echo('Custom Error'); } else { //Do t
by neurotech1 14y ago
so what is wrong with;
if(function_exists(custom_func) {
$x = @custom_func();
}
if((!isset($x)) || (empty($x))) {
echo('Custom Error');
} else {
//Do the work
}
This may be considered verbose, but can be useful if custom or "sometimes" installed libraries are involved
- jtreminio 14y ago> if(function_exists(custom_func) { $x = @custom_func(); } http://php.net/manual/en/function.call-user-func.php http://php.net/manual/en/function.call-user-func.php Why would you prepend @ to your function call? > if((!isset($x)) || (empty($x))) { echo('Custom Error'); } else { //Do the work } You're duplicating your efforts. empty() takes into account if a variable or key has been initialized, and also if it has a non-false value. isset() only checks if the variable/key has been intialized and nothing else.