Jump to content


Photo

Simple variable question


  • Please log in to reply
3 replies to this topic

#1 Cep

Cep
  • Members
  • PipPipPip
  • Advanced Member
  • 539 posts
  • LocationOn a boat in the middle of nowhere

Posted 06 April 2006 - 01:54 PM

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;


Thanks Cep

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 06 April 2006 - 01:59 PM

Not in php. Ruby can do this...
a,b = 1,2
Cool huh? But yeah... not php.

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 06 April 2006 - 02:07 PM

[!--quoteo(post=362222:date=Apr 6 2006, 09:59 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Apr 6 2006, 09:59 AM) View Post[/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:
// 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";

have fun with that!
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#4 Cep

Cep
  • Members
  • PipPipPip
  • Advanced Member
  • 539 posts
  • LocationOn a boat in the middle of nowhere

Posted 06 April 2006 - 02:09 PM

hehe thanks guys!
Thanks Cep




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users