Req #10546 [Com]: extract() to work with objects

From: Date: Thu, 19 Sep 2013 23:03:14 +0000
Subject: Req #10546 [Com]: extract() to work with objects
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-181697@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=10546&edit=1

 ID:                 10546
 Comment by:         metamarkers at gmail dot com
 Reported by:        fabiankessler at usa dot net
 Summary:            extract() to work with objects
 Status:             Assigned
 Type:               Feature/Change Request
 Package:            Class/Object related
 Operating System:   *
 PHP Version:        *
 Assigned To:        andrei
 Block user comment: N
 Private report:     N

 New Comment:

A blind import into an object would be neat for shortcutting certain things, but 
would undermine __set(). Consider instead:

function import ( $object , array $vars ) {
    foreach ($vars as $k=>$v) {
        $object->$k = $v;
    }
}


Previous Comments:
------------------------------------------------------------------------
[2001-04-29 01:06:34] fabiankessler at usa dot net

example:

class foo {
  function foo() {
    $var_array = array('hello'=>'world');
    extract($var_array, EXTR_PREFIX_ALL, "this->prefix");
    echo $this->prefix_hello;
  }
};
$f = new foo();

:)
fab


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=10546&edit=1


Thread (1 message)

  • metamarkers at gmail dot com
  • Unknown Message
    • metamarkers at gmail dot com
« previous php.bugs (#181697) next »