Created
December 17, 2008 04:22
-
-
Save mgng/36936 to your computer and use it in GitHub Desktop.
class -> array
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 Test { | |
private $a = 'private'; | |
public $b = 'public'; | |
} | |
$obj = new Test(); | |
$arr = (array)$obj; | |
echo $arr["\0Test\0a"]; // private | |
echo $arr["b"]; // public | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment