Two ampersands between function calls

What do the two ampersands sharing function calls do? Note: this is EXTERNAL any if or case statements

Same:

functionCallOne() && functionCallTwo();
+3
source share
4 answers

he is equivalent

if ( functionCallOne() ) {
  functionCallTwo();
}

it just uses a short circuit to make this 3 gigabyte just one line

+5
source

This is the AND short-circuit operator, that is, the second function (or expression / operator) will be evaluated only if the first returns true.

+5
source

( ) , false, PHP , true, false.

0

The logical operator AND &&is a short circuit operator. This means that it will only move to check the second operand if the first operand true. If the first operand false, the whole expression can only be false, so it makes no sense to check the second operand, so it closes with a short circuit from the operation without checking the second operand.

In this case, this characteristic is used to mean "complete functionCallOneand if it was successfully completed functionCallTwo."

0
source

Source: https://habr.com/ru/post/1773980/


All Articles