for example, in PHP code like this:
if($this->function1() && $this->function2())
{
//everything is alright
}
else
{
//function1 or function2 returned false
//whodunnit?
}
Is there a language construct or something that can help me find out the culprit in the else block? I don’t want to have to run the conditions once again, just to find out what went wrong.
Please bear with my pseudo-code. My actual code will look totally out-of-context here… and I’m using CodeIgniter, by the way.
This is somewhat ugly. I wouldn’t use it (= “for this purpose”).
Also I’m making this CW to eschew the downvotes.
This syntactic workaround necessitates that you can fill up the methods parameters with the required number and pass the fake
$failedparameter in an unused spot. It in fact just adds this variable to the local variable scope.You could redesign this if-statement more clumsily with more && ands and () parens to the same effect. This is just somewhat compacter. Yet I’m not sure if I understand why you would want a string with the failed function name, not just a boolean, or what’s up with the
ifphobia.