We launched new forums in March 2019—
join us there
.
In a hurry for help with your website?
Get Help Now!
Back to MODX.com
Forums
Docs
Revo Issues
Blog
My Forums
General
Webworker Lounge
Search
PHP- Syntax for giving two variables the same value ( in one line )
104 Posts
scraf
Reply #1,
19 years, 6 months ago
Is that possible?
I want to make this...
$foo = 1; $bar = 1;
Into something like....
$foo,$bar = 1;
... although without the parse error.
☆ A M B ☆
174 Posts
gildas
Reply #2,
19 years, 6 months ago
Variables can be assigned together like this :
$a = $b = 1;
Ackwa
- Web Design & Development agency | Tours - France |
Follow me on Twitter...
104 Posts
scraf
Reply #3,
19 years, 6 months ago
Stunning in it’s symplicity, thanks Gildas.
☆ A M B ☆
174 Posts
gildas
Reply #4,
19 years, 6 months ago
If you want, you can also play with "precedence"
$a = ($b = $c = 1) + 1;
Ackwa
- Web Design & Development agency | Tours - France |
Follow me on Twitter...