note 116290 deleted from oop4.magic-functions by sobak
| From: | sobak@php.net | Date: | Sun, 04 Dec 2016 07:15:31 +0000 |
| Subject: | note 116290 deleted from oop4.magic-functions by sobak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208027@lists.php.net to get a copy of this message | ||
Note Submitter: Ninsuo
----
If you want to serialize all but one properties, you can use:
<?php
class A
{
protected $a = 1;
protected $b = 2;
protected $c = 3;
protected $d = 4; // unwanted
public function __sleep()
{
return array_diff(array_keys(get_object_vars($this)), array('d'));
}
}