Don’t do that #1: Multiple lines to initialize variables

By | February 24, 2015

Don’t do that: The following code requires multiple lines (related to the same object) to initialize variables to 0.

Do that: In this specific case, it’s possible to initialize multiple variables in one line as related to the same object/concept:
$seconds = $minutes = $hours = $days = $weeks = $months = $years = 0

Having one line assignment (related to the same object/concept) could be easier to read that having one assignment per line.

Note: It’s also possible to assign different values to different variables in one line :
$a, $b = 1, 2


Leave a Reply

Your email address will not be published.