Samer
Samer

Reputation: 988

PHP Syntax Explanation for "and" keyword

I was looking at the Laravel 3 source code, and I saw a weird syntax in the larave/section.php file:

ob_start() and static::$last[] = $section;

What is this weird assignment syntax? How do you read it? Does it mean that we're assining $section to static::$last[] if ob_start() returns true?

Upvotes: 1

Views: 62

Answers (1)

Amadan
Amadan

Reputation: 198334

Yes. It is a shorthand for

if (ob_start()) { static::$last[] = $section; }

due to short-circuit nature of boolean operators.

Upvotes: 3

Related Questions