Search code examples
phpboolean-logicboolean-operations

PHP combined operator for &&?


I have code like this:

$finalResult = true;

$finalResult = $finalResult && function_01();
// some code here
$finalResult = $finalResult && function_02();
// some many lines of code here
$finalResult = $finalResult && function_XX();


And I'm looking for a way how to shorten the code (just for a human-readibility reasons) to something like:

$finalResult = true;

$finalResult &&= function_01();
// some code here
$finalResult &&= function_02();
// some many lines of code here
$finalResult &&= function_XX();

But of course this doesn't work and operator &= is not for boolean values, but for binary.

How should I do this ?
Thanks.


Solution

  • OK, after all it seems I will not get it any simpler than original.

    For those of you who don't understand why I want to have it in some "short" form - only reason was to have it shorter and nicer. Just the same reason why there is possibility to write $a += 3 just for beauty.

    Anyway, thanks to everybody :)