Created
March 10, 2016 11:25
-
-
Save mindplay-dk/d4afeb52086b7205ffc7 to your computer and use it in GitHub Desktop.
class or object???
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 | |
// anonymous classes are both instances and types. huh? what? | |
$type = new class { | |
public function foo() { | |
echo "YAY"; | |
} | |
}; | |
$type->foo(); // => "YAY" | |
$object = new $type(); | |
$object->foo(); // => "YAY" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lol, it's a class, just like any other but without a name.
What u are seeing is an object being instantiated from another object.
Try $type = new DateTime();