Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/08/2023 in all areas

  1. The empty string ('') will compare correctly using ==, because it's a string. This issue is specifically when you are testing a numeric value against a string. Somewhere in your code $sw is getting set to the numeric value 0 and not the empty string as you thought and that's what lead to the problem. In general, using strict comparison is a good habit to develop to save help ensure you're dealing with the correct types.
    1 point
  2. You're probably running a version of PHP before 8.0 and suffering from it's poor handling of comparing integers and strings. This was changed in PHP 8.0 to something that makes more sense. Compare the output if you run the code on various versions of PHP: https://3v4l.org/vLB4b The simple fix is to perform a strict comparison using the === operator instead. if($sw === 'B'){ print("sw=$sw<br>"); print("<font color=maroon>Buy $amt <font color=red>$sw<br>"); }
    1 point
  3. as of php8 - either update to php8+ or use a strict comparison ===
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.