タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

phpと比較に関するmetazyのブックマーク (2)

  • PHP - 型の比較表

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    PHP - 型の比較表
  • 90. 文字列から数値へのキャストの落とし穴

    PHPで何気なく使用している等号・不等号ですが、文字列と数値を比較しようとすると予期せぬ動きをすることがあります。今回はおちいりがちな落とし穴を紹介します。 まずは簡単に以下の5つについての比較を行ってみましょう。以下の6つはすべてブール値としてみるとfalseとなる値です。 1: null 2: false 3: 0 (integer) 4: "" (空文字) 5: "0" (string) 6: array() これを「==」で比較してみると以下のような結果となります。 |1|2|3|4|5|6 -------------------- 1|○|○|○|○|×|○ 2|○|○|○|○|○|○ 3|○|○|○|○|○|× 4|○|○|○|○|×|× 5|×|○|○|×|○|× 6|○|○|×|×|×|○ ×となっている組は(1,5), (3,6), (4,5), (4,6), (5,6)

    90. 文字列から数値へのキャストの落とし穴
  • 1