I'm calling a function to insert some thing in SQL, and I wanted to know if is it safe to have the function as second condition to an if statement, and if it would be called only when the first condition is true, and I would like to know if it would be good pratice too;
I know I could include another if inside that if, and it would work fine, but I'm trying not to include too many unnecessary if statements. It isn't the same as wanting to know if it's better to use nested IFs, because what I wanted to know was if the function would be called when the first condition evaluated to false or not.
if (empty($err) && InsertSQL($args)) {
echo "success";
} else {
$err .= "fail to insert";
}
echo $err;
I expect it to output success if there is no error in $err and the function returns true, and "fail to insert" and the other error if there is an error or if there is no error but the function returns false, I'll just get "fail to insert"