简体   繁体   中英

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;

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM