Skip to content

Instantly share code, notes, and snippets.

@mgng
Created December 17, 2008 04:22
Show Gist options
  • Save mgng/36936 to your computer and use it in GitHub Desktop.
Save mgng/36936 to your computer and use it in GitHub Desktop.
class -> array
<?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