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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 14:01:29 2024 UTC