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.
Printable View
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.
Ummmm
PHP Code:$object->variable = $newvariable;
PHP Code:list($o->v1, $o->v2, $o->v3) = $vars;
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.
Do you mean something like this?
PHP Code:foreach($_REQUEST As $key => $val) {
$user->$key = $val;
}
Thanks.
No problem! Glad that's what you needed. :)