note 57469 added to function.call-user-func

From: Date: Wed, 05 Oct 2005 08:42:34 +0000
Subject: note 57469 added to function.call-user-func
Groups: php.notes 
Request: Send a blank email to php-notes+get-96402@lists.php.net to get a copy of this message
>phil at gettcomm dot com >22-May-2002 04:51 >if you need to get a reference back from a method, you can work around >call_user_func()'s shortcomings like this: > Naaa! Having back a refererence is a real problem, but it can be solved by mean of eval(), instead of using call_user_func: <code> class Node { var $name; var $child; function Node ( $name ) { $this->name = $name; } function &getChild () { return $this->child; } } $p = new Node ( 'Father' ); $c = new Node ( 'Child' ); $p->child = &$c; eval ( "\\$cref = &\\$p->getChild ();" ); $cref->name = 'Another Child'; // Prints out 'Another Child' echo "****** After eval c = " . $c->name . "\\n\\n"; </code> ---- Manual Page -- http://www.php.net/manual/en/function.call-user-func.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57469 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57469&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57469&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57469&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57469&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57469&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57469&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57469&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57469&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#96402) next »