diff --git a/language/oop5/magic.xml b/language/oop5/magic.xml index 3ddea35f9d..da2fd17284 100644 --- a/language/oop5/magic.xml +++ b/language/oop5/magic.xml @@ -1,5 +1,5 @@ - + Magic Methods @@ -8,16 +8,17 @@ __destruct (see Constructors and Destructors), __call, + __callStatic, __get, __set, __isset, - __unset + __unset (see Overloading), __sleep, __wakeup, __toString, __set_state and - __clone + __clone are magical in PHP classes. You cannot have functions with these names in any of your classes unless you want the magic functionality associated @@ -160,6 +161,51 @@ Hello The only parameter of this method is an array containing exported properties in the form array('property' => value, ...). + + Using <literal>__set_state</literal> (since PHP 5.1.0) + +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); + +?> +]]> + + &example.outputs; + + + int(5) + ["var2"]=> + string(3) "foo" +} +]]> + +