note 37271 added to keyword.paamayim-nekudotayim

From: Date: Sat, 08 Nov 2003 01:20:34 +0000
Subject: note 37271 added to keyword.paamayim-nekudotayim
Groups: php.notes 
Request: Send a blank email to php-notes+get-60131@lists.php.net to get a copy of this message
Regarding the note by "gk at proliberty dot com". No, eval() isn't superior to call_user_func(), eval() has security issues and performance overhead. To achieve the same results using your example with call_user_func, simply pass $this_class by reference. This is probably because call_user_func is passing a copy of $this_class. <?php function init(&$this_class, $current_class, $params= NULL ){ $this_class->classFiles[] = __FILE__; $parent_class=get_parent_class($current_class); if( !empty($parent_class)){ // call_user_func() NOW DOES CORRECTLY UPDATE $this_class->classFiles :) call_user_func(array($parent_class,'init'), &$this_class,$parent_class,$params); } } // init() ?> But please note, call-time pass-by-reference has been deprecared, or at least, PHP 4.3.2 says so. Conclusion: Minimize using eval as much as possible, many projects had major security issues because they were using eval(). ---- Manual Page -- http://www.php.net/manual/en/keyword.paamayim-nekudotayim.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37271 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37271&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37271&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60131) next »