php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57516 protected/private members cannot be serialized
Submitted: 2007-02-08 18:49 UTC Modified: 2008-12-18 22:23 UTC
From: david dot seidel at prodyna dot com Assigned:
Status: Wont fix Package: json (PECL)
PHP Version: 5.2.0 OS: Windows XP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
25 - 1 = ?
Subscribe to this entry?

 
 [2007-02-08 18:49 UTC] david dot seidel at prodyna dot com
Description:
------------
It's not possible to serialize protected and/or private member variables.

Reproduce code:
---------------
<?php
class MyBean {
	protected $value = null;
	
	public function __construct() { 
		$this->value = "hallo";
	}
	
	public function setValue($value) {
		$this->value = $value;
	}
	
	public function getValue() {
		return $value;
	}
}
$a = new MyBean();
echo json_encode($a); 
?>

Expected result:
----------------
{"value":"hallo"}

Actual result:
--------------
{}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-18 22:23 UTC] scottmac@php.net
This is completely intentional looking at the code, if you 
wish to see this changed I'd open a bug report at 
http://bugs.php.net/
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jan 23 15:01:23 2021 UTC