chaddsuk Posted January 9, 2008 Share Posted January 9, 2008 Hi im having issues figureing out how the if statement works correctly im using the following... <?php $var = 5; if ($var == 5) ( echo "var was true<br>"; ) ?> ive found that if i remove the curly braces around my echo it works, but if i do that i cant insert code independent of the IF statment? Im using PHP5 btw any help would be appreciated cheers chris Quote Link to comment https://forums.phpfreaks.com/topic/85204-solved-newbie-php-question/ Share on other sites More sharing options...
nikefido Posted January 9, 2008 Share Posted January 9, 2008 $var = 5; if ($var == 5) { echo "var was true"; } use curly braces - you use () for the statement you are testing and {} for the code you want done I'm not sure what you mean by "independent of the if statement" ? you can add all the code you want that's not within the IF statement: $var = 5; //this is independent of the if statement if ($var == 5) { echo "var was true"; } //any code here will be independent of the IF statement Quote Link to comment https://forums.phpfreaks.com/topic/85204-solved-newbie-php-question/#findComment-434694 Share on other sites More sharing options...
chaddsuk Posted January 9, 2008 Author Share Posted January 9, 2008 hi thanks for that, was being stupid! thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/85204-solved-newbie-php-question/#findComment-434697 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.