fatalkaiser Posted April 22, 2007 Share Posted April 22, 2007 Can it be done? Ive been searching the net for ages looking for tutorials or examples and i cant find anything What im trying to do is something like this <? if ($variable == "blah") { $a = 1; $b = 2; $c = 3; }; { echo ($e . $f . $g); }; ?> Ive tried about a hundred different ways of doing it, but none of them print the three variables. Can someone tell me what im doing wrong or give me the correct coding for this? Quote Link to comment https://forums.phpfreaks.com/topic/48120-solved-defining-variables-within-if-statements/ Share on other sites More sharing options...
paul2463 Posted April 22, 2007 Share Posted April 22, 2007 why the braces around the echo statement <?php if ($variable == "blah") { $a = 1; $b = 2; $c = 3; }; echo "$a , $b , $c"; //would print out to screen 1 , 2 , 3 as long as $variable was equal to "blah" ?> Quote Link to comment https://forums.phpfreaks.com/topic/48120-solved-defining-variables-within-if-statements/#findComment-235169 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.