2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHPではif ($flag == true)というコードを書いてはいけない

Posted at

はじめに

便乗ネタ記事です。
(きっと似たような記事がいっぱいあるんだろうな...

何がダメか

php > $flag = 1;
php > var_dump($flag == true);
php shell code:1:
bool(true)

ってなってしまうから。
なので、

php > $flag = 1;
php > var_dump($flag === true);
php shell code:1:
bool(false)

って感じで === で比較しようぜって話でした。
PHPってほんとクソ言語ですね!(褒め言葉

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?