Skip to content
Advertisement

PSR-12 and assigning same value to multiple variables

Is it allowed to assign multiple variables on the same line in PSR-12?

For example:

$count = $score = 0;

Advertisement

Answer

Yes. If it’s not explicitly stated, then there is no standard. Either works.

Also, chain assignment like that just makes the code cleaner so I personally would not see a reason to why it should not be allowed.

https://www.php-fig.org/psr/psr-12/

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement