Created
October 18, 2019 07:13
-
-
Save predakanga/484a8df36d0878a72b3843ee2a7bbe36 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Foo { | |
public function __construct() { | |
$this->prop = 'a'; | |
$this->{'contains-minus'} = 'b'; | |
$this->{''} = 'c'; | |
} | |
} | |
$obj = new Foo(); | |
var_dump($obj->prop); // 'a' | |
var_dump($obj->contains-minus); // int(0) - notice: undefined property Foo::$contains, warning: undefined constant minus, assumed 'minus' | |
var_dump($obj->{'contains-minus'}); // 'b' | |
// var_dump($obj->); // Syntax error, unexpected ')' | |
// var_dump($obj->''); // Syntax error, unexpected '''' | |
var_dump($obj->{''}); // 'c' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment