index.php
Codice PHP:
<?php
namespace system\bootstrap;
use system\bootstrap\Blind;
use BaseHandler\BaseHandler2;
use BaseException\ExceptionHandler;
use test\prova\lol;
set_error_handler(array('system\bootstrap\Blind', 'errorHandler'), E_ALL);
spl_autoload_register(array('system\bootstrap\Blind', 'autoload'));
class Blind {
public function __construct() {
//lol::ok();
//\test\prova\lol::ok();
echo $s;
}
public static final function autoload($className) {
$namespaces = explode('\\', $className);
$method = array_pop($namespaces);
include('includes/'.implode('/', $namespaces).'.php');
}
public static final function errorHandler($errorNo, $message, $filename, $lineNo) {
throw new ExceptionHandler();
}
}
new Blind;
echo $s; mi serve per generare un errore da catchare.
includes/BaseHandler.php
Codice PHP:
<?php
namespace BaseHandler;
class BaseHandler2 extends \Exception {}
includes/BaseException.php
Codice PHP:
<?php
namespace BaseHandler;
class ExceptionHandler extends BaseHandler2 implements IException {
public function __construct($message = '', $code = 0, $description = '', \Exception $previous = null) {
parent::__construct((string) $message, (int) $code, $previous);
}
public function show() {
echo "ok";
}
}
Errore:
Fatal error: Cannot redeclare class BaseHandler\BaseHandler2 in \includes\BaseHandler.php on line 6