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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: david dot seidel at prodyna dot com
New email:
PHP Version: OS:

 

 [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: Thu Apr 18 22:01:28 2024 UTC