adrumsolo4u Posted February 26, 2007 Share Posted February 26, 2007 i am trying to write a simple "if" function, which would work fine in C++ but php doesn't like it much if ((empty($sub1)) || ($sub0 = home)) { echo ' some text'; } what i want this to do is IF ((sub1 is empty) OR (sub0 = home)) echo ' this stuff '; i know this should work, have i made any errors? Link to comment https://forums.phpfreaks.com/topic/40214-solved-what-if/ Share on other sites More sharing options...
obsidian Posted February 26, 2007 Share Posted February 26, 2007 Well, you're not doing a comparison with the second half of your "if"... remember that "=" is assignment while "==" is comparison: <?php if (empty($sub1) || ($sub0 == 'home')) { } ?> Link to comment https://forums.phpfreaks.com/topic/40214-solved-what-if/#findComment-194569 Share on other sites More sharing options...
adrumsolo4u Posted February 26, 2007 Author Share Posted February 26, 2007 i tried using == as well as = i also tried inserting the ' ' around the home, and taking them away the results are all the same. Link to comment https://forums.phpfreaks.com/topic/40214-solved-what-if/#findComment-194576 Share on other sites More sharing options...
nloding Posted February 26, 2007 Share Posted February 26, 2007 There's nothing wrong with obsidians code. If you have that, then your variable isn't empty, and it doesn't equal "home". Link to comment https://forums.phpfreaks.com/topic/40214-solved-what-if/#findComment-194580 Share on other sites More sharing options...
adrumsolo4u Posted February 27, 2007 Author Share Posted February 27, 2007 i found a problem in my code. i had previously been using one integer, then i switched it's name, except for one, which i must have over looked, my code works fine now, but thanks anyway Link to comment https://forums.phpfreaks.com/topic/40214-solved-what-if/#findComment-195421 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.