Skip to content

Instantly share code, notes, and snippets.

@clemherreman
Created April 22, 2011 09:50
Show Gist options
  • Save clemherreman/936364 to your computer and use it in GitHub Desktop.
Save clemherreman/936364 to your computer and use it in GitHub Desktop.
PHP WTF of the day
<?php
class Person
{
private $phone;
private $name;
public function __construct($name, $phone)
{
var_dump($name);
var_dump($phone);
$this->name = $name;
$this->phone = $phone;
}
}
<?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*
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