0
if ($opts['width'] == 'fs' || $opts['height'] == 'fs' || $opts['ratio'] == 'fs') {
    var_dump($opts); // result of this see bellow
}

Result of var_dump($opts) inside (!) if-statement:

array(3) {
   'width' => int(200)
   'height' => int(0)
   'ratio' => int(0)
}

How is this possible? None of the array's values is (stirng) fs?

ndeverge
  • 21,378
  • 4
  • 56
  • 85
jakub_jo
  • 1,494
  • 17
  • 22

1 Answers1

3

Because 0 == 'fs'. See this conversion table.

PHP has the === operator to compare both value and type.

For a more extensive table: Type-juggling and (strict) greater/lesser-than comparisons in PHP

Community
  • 1
  • 1
Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
  • Thank you for the conversion table link. But in my opinion that's in someway weird. 0 should not evaluatue true to (string) 'fs'. Anyway, I've saved the link for the future! – jakub_jo Aug 24 '13 at 18:25
  • @mcj: In PHP, if `A == B` and `B == C` it doesn't mean that `A == C`. – Madara's Ghost Aug 24 '13 at 18:27