Page 1 of 1
if strcmp fail?
Posted: Sun Feb 28, 2010 8:20 pm
by Cirdan
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) {
Re: if strcmp fail?
Posted: Sun Feb 28, 2010 9:54 pm
by requinix
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") {
Re: if strcmp fail?
Posted: Sun Feb 28, 2010 10:02 pm
by Cirdan
Okay, the problem was I should have been using && not ||, and should have been using !=
EDIT: thanks!