Download - PHP WTF
![Page 1: PHP WTF](https://reader036.vdocument.in/reader036/viewer/2022080215/55b6e39dbb61eb75268b491f/html5/thumbnails/1.jpg)
PHP WTHA short tour of pain & fire.
![Page 2: PHP WTF](https://reader036.vdocument.in/reader036/viewer/2022080215/55b6e39dbb61eb75268b491f/html5/thumbnails/2.jpg)
list()
list($a, $a) = array(1, 2, 3, 4); echo $a; // 1 // WTH
![Page 3: PHP WTF](https://reader036.vdocument.in/reader036/viewer/2022080215/55b6e39dbb61eb75268b491f/html5/thumbnails/3.jpg)
in_array()
$a = array('7.1'); $exists = in_array('7.10', $a); var_dump($exists); // true // WTH
![Page 4: PHP WTF](https://reader036.vdocument.in/reader036/viewer/2022080215/55b6e39dbb61eb75268b491f/html5/thumbnails/4.jpg)
Private ORLYclass Human { private $name; function __construct($name) { $this->name = $name; } public function touch($human) { echo “Touched $human->name”; } }
$sally = new Human(‘sally’); $joe = new Human(‘joe’); $sally->touch($joe); // Touched joe
![Page 5: PHP WTF](https://reader036.vdocument.in/reader036/viewer/2022080215/55b6e39dbb61eb75268b491f/html5/thumbnails/5.jpg)
==$a = 0; $b = 'x'; false == $a; // true
$a == $b; // true
$b == true; // true // FFFFFFUUUUUU
![Page 6: PHP WTF](https://reader036.vdocument.in/reader036/viewer/2022080215/55b6e39dbb61eb75268b491f/html5/thumbnails/6.jpg)
Post increment
$a = 4; echo $a+++$a++; // 9 // WAT
![Page 7: PHP WTF](https://reader036.vdocument.in/reader036/viewer/2022080215/55b6e39dbb61eb75268b491f/html5/thumbnails/7.jpg)
Floats
$a = 0.1 * 0.1; var_dump($a); // double(0.01)
var_dump($a == 0.01); // false // ARRRRRGGGG
![Page 8: PHP WTF](https://reader036.vdocument.in/reader036/viewer/2022080215/55b6e39dbb61eb75268b491f/html5/thumbnails/8.jpg)
Ternaries
echo (true ? 'Foo' : false ? 'Bar' : ‘Baz' ); // Bar // NOOOOOO
![Page 9: PHP WTF](https://reader036.vdocument.in/reader036/viewer/2022080215/55b6e39dbb61eb75268b491f/html5/thumbnails/9.jpg)
Be Careful