Click to See Complete Forum and Search --> : Opposite to get_object_vars
nebulom
Jul 31st, 2007, 09:30 PM
Is there a way I can set a list of variables to the member variables of a class? Something like I can get variables with get_object_vars but how do I do the reverse thing?
Thanks.
RudiVisser
Aug 1st, 2007, 05:47 AM
Ummmm
$object->variable = $newvariable;
penagate
Aug 1st, 2007, 06:26 AM
list($o->v1, $o->v2, $o->v3) = $vars;
nebulom
Aug 2nd, 2007, 04:02 AM
Thanks guys. I'm thinking of doing hard coding. Something like
$user->user_name = getRequestParameter('user_name')
where getting from request is $_REQUEST[$someParam] or even $_POST[$someParam]. I was just thinking if can I automate the assignment like
<input type="text" name="user_name" will get to $user->user_name or something like that. Anyway I can hard code it like $user->someProperty = fromSomeValue but would be glad if I can do the assignment in one snap.
Again, thanks a bunch.
RudiVisser
Aug 2nd, 2007, 04:09 AM
Do you mean something like this?
foreach($_REQUEST As $key => $val) {
$user->$key = $val;
}
nebulom
Aug 2nd, 2007, 07:57 PM
Thanks.
RudiVisser
Aug 4th, 2007, 07:58 AM
No problem! Glad that's what you needed. :)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.