note 78198 rejected from language.oop5.autoload by ezyang
| From: | ezyang@php.net | Date: | Wed, 03 Oct 2007 01:20:12 +0000 |
| Subject: | note 78198 rejected from language.oop5.autoload by ezyang | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-130999@lists.php.net to get a copy of this message | ||
Note Submitter: vha at abv dot bg
----
Is it secure to do things this way:
<?
function __autoload($class_name)
{
switch($class_name)
{
case 'class1':
include('path\class1.php');
break;
case 'class2':
include('path\class2.php');
break;
case 'class3':
include('path\class1.php');
break;
}
}
?>
and are there any benefits in using it in an array:
<?
$classes = array(
'class1' => 'path\class1.php';
'class2' => 'path\class2.php';
'class3' => 'path\class3.php';
);
function __autoload($class_name)
{
global $classes;
if(isset($classes[$class_name]))
{
include($classes[$class_name]);
}
}
?>
What about the performace issues/benefits using this type for including many files than including
them one by one (hard coded)?
http://www.lanix.org/ica/