When I want to pass values into a PHP constructor I have to go: class Rump { private $var1; private $var2; private $var3; public function __construct($var1, $var2, $var3) { $…
Tag: variable-assignment
Assign same value to multiple variables at once?
How can I assign the same value for multiple variables in PHP at once ? I have something like: $var_a = ‘A’; $var_b = ‘A’; $same_var = ‘A’; $var_d = ‘A’; $some_var =’A’; In my case, I can’t rename …
How to assign a variable to one of two strings if one is blank?
I am wondering why this doesn’t work to assign a string to $separator: Elsewhere, $option has been assigned to some text or an empty string. (Actually, in my real life case, it’s some text, or FALSE, but either way…). $separator is TRUE instead of a string. The following accomplishes what I want, but seems unnecessarily verbose: I come from JavaScript,