php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #10546 extract() to work with objects
Submitted: 2001-04-29 01:06 UTC Modified: 2016-08-07 04:54 UTC
Votes:7
Avg. Score:3.0 ± 1.5
Reproduced:3 of 6 (50.0%)
Same Version:1 (33.3%)
Same OS:0 (0.0%)
From: fabiankessler at usa dot net Assigned:
Status: Suspended Package: Class/Object related
PHP Version: * OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2001-04-29 01:06 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-16 17:41 UTC] jani@php.net
-Package: Feature/Change Request +Package: Class/Object related -Operating System: all +Operating System: * -PHP Version: 4.0.4 +PHP Version: *
 [2013-09-19 23:03 UTC] metamarkers at gmail dot com
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;
    }
}
 [2016-08-06 00:31 UTC] kalle@php.net
-Status: Assigned +Status: Closed -Assigned To: andrei +Assigned To: kalle
 [2016-08-06 00:31 UTC] kalle@php.net
I'm gonna close this, such a feature would need a healthy discussion on the mailing list which most likely will end in an RFC.

All in all I'm not a huge fan of this, but every idea deserves a chance
 [2016-08-06 09:35 UTC] nikic@php.net
-Status: Closed +Status: Suspended
 [2016-08-06 09:35 UTC] nikic@php.net
By convention "Suspended" is our "Needs RFC" state.
 [2016-08-07 04:54 UTC] kalle@php.net
-Assigned To: kalle +Assigned To:
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 00:01:28 2024 UTC