|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-09-09 13:44 UTC] cmb@php.net
-Status: Open
+Status: Verified
-Type: Bug
+Type: Documentation Problem
-Assigned To:
+Assigned To: cmb
[2015-09-09 13:44 UTC] cmb@php.net
[2015-09-09 14:12 UTC] cmb@php.net
[2015-09-09 14:13 UTC] cmb@php.net
-Status: Verified
+Status: Closed
[2015-09-09 14:13 UTC] cmb@php.net
[2015-09-13 20:43 UTC] derick@php.net
[2019-08-06 23:45 UTC] roy-orbison at devo dot net dot au
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 22:00:01 2025 UTC |
Description: ------------ Though var_export() is designed to "outputs or return a parsable string representation of a variable", the output of stdClass objects is not "a parsable string". Witness: php > $foo = new stdClass(); php > var_export($foo); stdClass::__set_state(array( )) php > $bar = stdClass::__set_state(array()); PHP Fatal error: Call to undefined method stdClass::__set_state() in php shell code on line 1 PHP Stack trace: PHP 1. {main}() php shell code:0 PHP 2. {main}() php shell code:0 Relevant quote from the fine manual: > var_export() gets structured information about the given variable. It > is similar to var_dump() with one exception: the returned representation > is valid PHP code. Note that the output presented above is not valid PHP code. It seems that bug #48016 attacks the same issue from the other side (stdClass::__setState is not defined although var_export uses it), however that bug was closed prematurely, as the test case used to justify the close does not demonstrate that the issue is resolved. Test script: --------------- $ php -a php > $foo = new stdClass(); php > var_export($foo); stdClass::__set_state(array( )) php > $bar = stdClass::__set_state(array()); PHP Fatal error: Call to undefined method stdClass::__set_state() in php shell code on line 1 PHP Stack trace: PHP 1. {main}() php shell code:0 PHP 2. {main}() php shell code:0