Results 1 to 7 of 7

Thread: Opposite to get_object_vars

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Resolved 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.

  2. #2
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    Ubuntu Haters Club
    Posts
    405

    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.

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Opposite to get_object_vars

    PHP Code:
    list($o->v1$o->v2$o->v3) = $vars

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    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.

  5. #5
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    Ubuntu Haters Club
    Posts
    405

    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.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Re: Opposite to get_object_vars

    Thanks.

  7. #7
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    Ubuntu Haters Club
    Posts
    405

    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
  •  



Click Here to Expand Forum to Full Width