Jump to content

Archived

This topic is now archived and is closed to further replies.

Cep

Simple variable question

Recommended Posts

I just had a thought but is it possible to declare a value for several variables at the same time?

Maybe by doing this,

$myVar, $myOther = 1;

Share this post


Link to post
Share on other sites
Not in php. Ruby can do this...
[code]
a,b = 1,2
[/code]
Cool huh? But yeah... not php.

Share this post


Link to post
Share on other sites
[!--quoteo(post=362222:date=Apr 6 2006, 09:59 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Apr 6 2006, 09:59 AM) [snapback]362222[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Not in php.
[/quote]

actually, you can assign multiple variables the same value! it looks a little funny in practice, though:
[code]
// here's the principle
$myVar = $myOther = 1;

// you can link as many as you'd like. check this out:
$one = $two = $three = $four = 1;
echo "$one, $two, $three, $four";
[/code]

have fun with that!

Share this post


Link to post
Share on other sites
hehe thanks guys!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.