function __autoload($class_name) {
require_once 'clas/'.$class_name . '.php';
}
Хотелось бы услышать мнения как способ нормальный?
_____________
Вязание xe4.ru спицами.
Сайт для тестов (подопытный №543)
function __autoload($class_name) {
require_once 'clas/'.$class_name . '.php';
}
include_once 'clas/'.$class_name . '.php';
echo "Hallo";
Warning: include_once(clas/.php) [function.include-once]: failed to open stream: No such file or directory in Z:\home\oop.ma\www\index.php on line 13
Warning: include_once() [function.include]: Failed opening 'clas/.php' for inclusion (include_path='.;/usr/local/php5/PEAR') in Z:\home\oop.ma\www\index.php on line 13
Fatal error: Class 'test' not found in Z:\home\oop.ma\www\index.php on line 17
echo "Hallo";
error_reporting(E_ALL);
header("Content-type: text/html; charset=utf-8");
define("VAS_HOME", $_SERVER['DOCUMENT_ROOT']);
include VAS_HOME."/clas/".$class_name.".php";
$class_name
?
class test{
function tes($a, $s){
$z = $a * $s;
return $z;
}
}
function __autoload($class_name) {
require_once 'clas/'.$class_name . '.php';
}
$a = new test();
echo $a->tes(3, 2);
error_reporting(E_ALL);
header("Content-type: text/html; charset=utf-8");
define("VAS_HOME", $_SERVER['DOCUMENT_ROOT']);
include VAS_HOME."/clas/".$class_name.".php";
$a = new test();
echo $a->tes(3, 2);
Warning: Cannot modify header information - headers already sent by (output started at Z:\home\oop.ma\www\index.php:12) in Z:\home\oop.ma\www\index.php on line 14
Notice: Undefined variable: class_name in Z:\home\oop.ma\www\index.php on line 18
[Денвер: показать возможную причину ошибки]
Warning: include(Z:/home/oop.ma/www/clas/.php) [function.include]: failed to open stream: No such file or directory in Z:\home\oop.ma\www\index.php on line 18
Warning: include() [function.include]: Failed opening 'Z:/home/oop.ma/www/clas/.php' for inclusion (include_path='.;/usr/local/php5/PEAR') in Z:\home\oop.ma\www\index.php on line 18
Fatal error: Class 'test' not found in Z:\home\oop.ma\www\index.php on line 21
Warning: include(Z:/home/oop.ma/www/clas/.php)
$class_name
такчто может мы друг друга не правильно поняли