RE: [PHP] Automatic include of files containing functions

From: Date: Wed, 11 Dec 2002 22:23:45 +0000
Subject: RE: [PHP] Automatic include of files containing functions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-127920@lists.php.net to get a copy of this message
Here is what I am looking at for a partial solutions (see "redirect missing function error" for my next hurdle)... All functions are contained within individual files in a "functions" directory, none of which are hard included into the PHP pages; eg// ./functions/ShowThis.php ./functions/ShowThat.php ./functions/ShowOther.php in each PHP page... <?PHP function func($f_name){ if(!function_exists($f_name)){ require('/path/to/functions/'.$f_name.'.php'); }else{ # function already exists, no action required } return $f_name; } ?> Now when we want to call functions, we use the following syntax... instead of; $MyInfo=ShowOther($someVariable); we use; $MyInfo=call_user_func(func('ShowOther'),$someVariable); This seems to accomplish what I want which is to remove my large 30 function text file from being loaded for every page when some pages only require one of the functions in the file. Comments? Dave

« previous php.general (#127920) next »