Last active
November 9, 2018 22:36
-
-
Save bagart/60ed34f9e851a2b9e16a3f92e83e2f33 to your computer and use it in GitHub Desktop.
array with double key
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 A { | |
private $omg = 'A'; | |
function dump() { | |
return get_object_vars($this); | |
} | |
} | |
class B extends A { | |
public $omg = 'B'; | |
} | |
var_dump((new B())->dump()); | |
$q = (new B())->dump(); | |
var_dump([ | |
'is_array' => is_array($q), | |
'is_object' => is_object($q), | |
'dump' => $q, | |
'dump+' => $q + ['omg'=>1], | |
'+dump' => ['omg'=>1] + $q | |
]); | |
var_dump([ | |
'0 curr ' . current($q) => $x0 = key($q), | |
'1 next ' . next($q) => $x1 = key($q), | |
'2 prev ' . prev($q) => $x2 = key($q), | |
"0 === 1" => $x0 === $x1, | |
"0 === 2" => $x0 === $x2, | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PHP 7.0 - 7.1 - 7.2 - 7.3RC