note 100248 added to function.get-class-vars
| From: | ken at verango dot com | Date: | Mon, 04 Oct 2010 11:50:25 +0000 |
| Subject: | note 100248 added to function.get-class-vars | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172931@lists.php.net to get a copy of this message | ||
Correction:
I wish to omit the last post, all 3 of get_object_vars, get_class_vars and reflection
getDefaultProperties will reveal the name of the array. For serialization I recommend:
$cName = get_class($this);
$varTemplate= get_class_vars($cName)
foreach ($varTemplate as $name => $defaultVal) {
$vars[$name] = $this->$name; // gets actual val.
}
No scan the $vars and create serialization string how you wish.
This protects against erroneous prior deserializing in maintaining the integrity of the class
template and ignoring unintended object properties.
----
Server IP: 64.71.164.2
Probable Submitter: 24.189.3.65
----
Manual Page -- http://www.php.net/manual/en/function.get-class-vars.php
Edit -- https://master.php.net/note/edit/100248
Del: integrated -- https://master.php.net/note/delete/100248/integrated
Del: useless -- https://master.php.net/note/delete/100248/useless
Del: bad code -- https://master.php.net/note/delete/100248/bad+code
Del: spam -- https://master.php.net/note/delete/100248/spam
Del: non-english -- https://master.php.net/note/delete/100248/non-english
Del: in docs -- https://master.php.net/note/delete/100248/in+docs
Del: other reasons-- https://master.php.net/note/delete/100248
Reject -- https://master.php.net/note/reject/100248
Search -- https://master.php.net/manage/user-notes.php