Created
April 22, 2011 09:50
-
-
Save clemherreman/936364 to your computer and use it in GitHub Desktop.
PHP WTF of the day
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Person | |
{ | |
private $phone; | |
private $name; | |
public function __construct($name, $phone) | |
{ | |
var_dump($name); | |
var_dump($phone); | |
$this->name = $name; | |
$this->phone = $phone; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo 'Normal person:'.PHP_EOL; | |
$john = new Person('John', '544-555-3598'); // No problems | |
echo 'Phoneless person:'.PHP_EOL; | |
$john = new Person('John'); // Doesn't throw an Exception, only an E_warning, and *KEEP RUNNING* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Normal person: | |
string(4) "John" | |
string(12) "544-555-3598" | |
Warning: Missing argument 2 for Person::__construct(), called in (...)/example.php on line 6 and defined in (...)/Person.class.php on line 7 | |
Phoneless person: | |
string(4) "John" | |
NULL | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment