note 117713 added to function.var-export

From: Date: Mon, 27 Jul 2015 22:45:54 +0000
Subject: note 117713 added to function.var-export
Groups: php.notes 
Request: Send a blank email to php-notes+get-203198@lists.php.net to get a copy of this message
When trying to use __set_state() to rebuild a huge, tricky class use the following: class Foo { public $a; public $b; public $c; public $d; public $e; public $f; public $g; public $h; public $i; public function __set_state($array) { $obj = new ArrayConfig; foreach($array as $k => $v) { eval('$obj->'.$k.' = '.$v.';'); } return $obj; } } This will return a reconstructed version of the class without having to manually type each individual object in the class manually (as shown in the __set_state() example) ---- Server IP: 72.52.91.14 Probable Submitter: 207.140.105.155 ---- Manual Page -- http://php.net/manual/en/function.var-export.php Edit -- https://master.php.net/note/edit/117713 Del: integrated -- https://master.php.net/note/delete/117713/integrated Del: useless -- https://master.php.net/note/delete/117713/useless Del: bad code -- https://master.php.net/note/delete/117713/bad+code Del: spam -- https://master.php.net/note/delete/117713/spam Del: non-english -- https://master.php.net/note/delete/117713/non-english Del: in docs -- https://master.php.net/note/delete/117713/in+docs Del: other reasons-- https://master.php.net/note/delete/117713 Reject -- https://master.php.net/note/reject/117713 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203198) next »