|
-
Jul 31st, 2007, 09:30 PM
#1
Thread Starter
Fanatic Member
Opposite to get_object_vars
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.
Last edited by nebulom; Aug 2nd, 2007 at 07:58 PM.
-
Aug 1st, 2007, 05:47 AM
#2
Hyperactive Member
Re: Opposite to get_object_vars
Ummmm
PHP Code:
$object->variable = $newvariable;
» Twitter: @rudi_visser : Website: www.rudiv.se «
If Apple fixes security flaws, they are heralded as proactive. If Microsoft fixes a security flaw, they finally got around to fixing their buggy OS.
-
Aug 1st, 2007, 06:26 AM
#3
Re: Opposite to get_object_vars
PHP Code:
list($o->v1, $o->v2, $o->v3) = $vars;
-
Aug 2nd, 2007, 04:02 AM
#4
Thread Starter
Fanatic Member
Re: Opposite to get_object_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.
-
Aug 2nd, 2007, 04:09 AM
#5
Hyperactive Member
Re: Opposite to get_object_vars
Do you mean something like this?
PHP Code:
foreach($_REQUEST As $key => $val) {
$user->$key = $val;
}
» Twitter: @rudi_visser : Website: www.rudiv.se «
If Apple fixes security flaws, they are heralded as proactive. If Microsoft fixes a security flaw, they finally got around to fixing their buggy OS.
-
Aug 2nd, 2007, 07:57 PM
#6
Thread Starter
Fanatic Member
Re: Opposite to get_object_vars
-
Aug 4th, 2007, 07:58 AM
#7
Hyperactive Member
Re: Opposite to get_object_vars
No problem! Glad that's what you needed.
» Twitter: @rudi_visser : Website: www.rudiv.se «
If Apple fixes security flaws, they are heralded as proactive. If Microsoft fixes a security flaw, they finally got around to fixing their buggy OS.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|