PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Cirdan
Forum Contributor
Posts: 144 Joined: Sat Nov 01, 2008 3:20 pm
Post
by Cirdan » Sun Feb 28, 2010 8:20 pm
I have this if statement, which fails when the mode is "reply". It works fine if the mode is "thread". I can't see the reason why it would fail.
Code: Select all
if(strcmp($this->_mode, 'thread') < 0 || strcmp($this->_mode, 'reply') < 0) {
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Sun Feb 28, 2010 9:54 pm
strcmp returns something <0
if the first argument is less than the second . You'd want ==0 or !=0...
...if there was any point in using strcmp in the first place. PHP isn't C or Java: you can compare strings just fine.
Code: Select all
if($this->_mode == "thread" || $this->_mode == "reply") {
Cirdan
Forum Contributor
Posts: 144 Joined: Sat Nov 01, 2008 3:20 pm
Post
by Cirdan » Sun Feb 28, 2010 10:02 pm
Okay, the problem was I should have been using && not ||, and should have been using !=
EDIT: thanks!