Php array transcoding publicfunctionarray_iconv ($ in_charset, $ out_charset, $ arr) {returneval ('Return '. iconv ($ in_charset, $ out_charset, var_export (php array transcoding problem)
Public function array_iconv ($ in_charset, $ out_charset, $ arr ){
Return eval ('Return '. iconv ($ in_charset, $ out_charset, var_export ($ arr, true ).';'));
}
This problem occurs during transcoding.
Fatal error: Call to undefined method stdClass ::__ set_state () in D: \ soft \ apache \ htdocs \ webtest \ arrayiconv. func. php (5): eval () 'd code on line 1
------ Solution --------------------
The manual includes:
_ Set_state ()
Static object _ set_state (array $ properties)
When var_export () is called, this static method is called (effective from PHP 5.1.0 ).
The unique parameter of this method is an array, which contains class attributes in array ('properties' => value,...) format.
Example #4 use _ set_state ()> (supported by PHP 5.1.0 and later)
PHP code
var1 = $an_array['var1']; $obj->var2 = $an_array['var2']; return $obj; }}$a = new A;$a->var1 = 5;$a->var2 = 'foo';eval('$b = ' . var_export($a, true) . ';'); // $b = A::__set_state(array( // 'var1' => 5, // 'var2' => 'foo', // ));var_dump($b);?>