note 102945 added to reserved.keywords

From: Date: Wed, 16 Mar 2011 01:24:38 +0000
Subject: note 102945 added to reserved.keywords
Groups: php.notes 
Request: Send a blank email to php-notes+get-177924@lists.php.net to get a copy of this message
As another note, to the previously mentioned comment, here's another alternative that will allow you to map names based on an array (a private map variable) this also degrades pretty well into PHP 4 versions, you can use this to your advantage handling slow adopters, as well as early adopters. This is an example from a download class I'm building for CodeIgniter <?php class Download { private $ci = NULL; private $map = array( 'file' => '_obscure_or_referenced_name', 'list' => '_obscure_or_referenced_name_two', ); public function __construct($config=array()) { /* Perform an action or so */ } /* Force Download a file */ public function _obscure_or_referenced_name($arg1,$arg2=NULL){ /* Do Download Code Here */ } public function _obscure_or_referenced_name_two($arg){ /* Do Download Code Here */ } public function __call($func, $args) { if(!method_exists($this,$func)){ return call_user_func_array(array($this,$func),$args); } else { if(in_array($func,$this->map)){ return call_user_func_array(array($this,$this->map[$func]),$args); } else { trigger_error("Call to undefined method ".__CLASS__."::$func()", E_USER_ERROR); } } } } ?> I believe this to be a slightly better alternative to the previously mentioned one. There are some debates on the use of call_user_func_array (http://php.net/call_user_func_array) in a class like this, it does have some small performance differences, but not enough in my opinion to warrant using the harder/fixated route. this gives expansion a simple touch. ---- Server IP: 69.147.83.197 Probable Submitter: 208.88.8.10 ---- Manual Page -- http://www.php.net/manual/en/reserved.keywords.php Edit -- https://master.php.net/note/edit/102945 Del: integrated -- https://master.php.net/note/delete/102945/integrated Del: useless -- https://master.php.net/note/delete/102945/useless Del: bad code -- https://master.php.net/note/delete/102945/bad+code Del: spam -- https://master.php.net/note/delete/102945/spam Del: non-english -- https://master.php.net/note/delete/102945/non-english Del: in docs -- https://master.php.net/note/delete/102945/in+docs Del: other reasons-- https://master.php.net/note/delete/102945 Reject -- https://master.php.net/note/reject/102945 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#177924) next »