Code: Select all
$txnResponseCode = "E";
if ($txnResponseCode != "0") {
echo 'fail<br>';
} else {
echo 'success<br>';
}
if ($txnResponseCode != 0) {
echo 'fail<br>';
} else {
echo 'success<br>';
}Moderator: General Moderators
Code: Select all
$txnResponseCode = "E";
if ($txnResponseCode != "0") {
echo 'fail<br>';
} else {
echo 'success<br>';
}
if ($txnResponseCode != 0) {
echo 'fail<br>';
} else {
echo 'success<br>';
}Code: Select all
if ((string) $txnResponseCode !== (string) 0) {
} else {
}
WHAT?!! You READ THE MANUAL?!! That's heresy!jackpf wrote:I had problems with this, when comparing a variable's value to 0 with in_array().
No matter what the value was, it would always return true when comparing to 0.
After reading the manual, it turns out that in_array() has a third parameter [, bool $strict], which, when set to true, also checks datatypes.
I know...it's hard to believe that some people actually read the manual before asking for helpcalifdon wrote:WHAT?!! You READ THE MANUAL?!! That's heresy!jackpf wrote:I had problems with this, when comparing a variable's value to 0 with in_array().
No matter what the value was, it would always return true when comparing to 0.
After reading the manual, it turns out that in_array() has a third parameter [, bool $strict], which, when set to true, also checks datatypes.