PHP Shortcut to Set Two Values at Once
I’ve been coding in php for seven years, and doing it professionally for four. Until today, I never knew you could use a syntax like this to set the value of more than one variable.
1 2 |
$variable_x = $variable_y = 0; |
I’m not sure why I’m so giddy about finding this shortcut. Is it really so much more troublesome to type out something like,
1 2 3 |
$variable_x = 0; $variable_y = 0; |
It took two extra keystrokes. A semicolon and a stroke of the enter key. But for some reason, I’m giddy like a schoolgirl.