php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #35846 var_export() generate invalid code
Submitted: 2005-12-30 02:00 UTC Modified: 2006-01-03 18:14 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: xing at mac dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.1.2RC1 OS: centos 4.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: xing at mac dot com
New email:
PHP Version: OS:

 

 [2005-12-30 02:00 UTC] xing at mac dot com
Description:
------------
invalid php code from var_export contrary to documentation claims.

Reproduce code:
---------------
<?


class query_result   {
	
	public $affected_rows = 0; 
	public $num_rows = 0; 
	public $insert_id = 0;

	public $result = array(); //pdo result
	public $pointer = 0;
}


$test = array(
"test" => new query_result()
);

$dump =  var_export($test, TRUE);

file_put_contents("test.txt","<? ". $dump . "?>");

include("test.txt");

die();

?>

Expected result:
----------------
no php error

Actual result:
--------------
PHP Fatal error: Call to undefinied query_result::__set_state() in test.txt line 3

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-30 06:45 UTC] sniper@php.net
There is no such function in PHP that can handle fatal errors any other way than as a fatal error.
 [2005-12-30 10:47 UTC] derick@php.net
I don't think this is documented though...
 [2006-01-03 18:14 UTC] vrana@php.net
Meaning of __set_state() is explained in var_export() documentation.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 19 17:00:02 2025 UTC