//dołączony.php <? # Global variable - check point class Error_Handler extends Exception { /** * @var string * @access private */ private $error_messages; /** * Construct * @param string $message Message from exception * @param int $code Code of exception * @access public */ public function __construct($message=null, $code = 0) { $this->load_errors(); # We make sure that everything is asigned properly parent::__construct($message, $code); } /** * Loading all errors * @return bool * @access private */ private function load_errors() { return false; foreach ($ERRORS as $key => $value){ $this->error_messages[$key] = $value; } return true; } /** * Display errors (Param $message from __construct) * @return void * @access public */ public function alert() { } } // US English $ERRORS[\"SAMPLE_ERR_CODE\"] = \"This is an error message.\"; $ERRORS[\"SAMPLE\"] = \"This.\"; try { throw new Error_Handler('SAMPLE_ERR_CODE');} catch (Error_Handler $e){ $e->alert();} ?>
metoda function load_errors() nie widzi tablicy $ERRORS i nie może wczytać sobie komunikatu. Jeżeli normlanie plik dołączony dam jako
<?php require_once $plik.php ?>
To wszystko działa jak powinno. Stąd moje pytanie czy __autoload() chodź ma np. w manualu w swoim ciele require* to dołancza tylko interfejsy klas czy poprostu tylko je zwraca bo jeżeli dam tak :
<?php function __autoload($klasa) { require_once $plik . '.php'; // i teraz } ?>
to widzi zmienną z tablicy.