Ho un primo file che è l seguente:
<?php
require('Smarty.class.php');
include_once 'includes/controller.php';
$mycontroller = new controller;
?>
che include il secondo:
<?php
class controller {
public $vista;
public $modello;
function controller() {
$this->vista = new Smarty;
$this->vista->template_dir = '/usr/local/apache2/htdocs/smarty/templates';
$this->vista->compile_dir = '/usr/local/apache2/htdocs/smarty/templates_c';
$this->vista->config_dir = '/usr/local/apache2/htdocs/smarty/configs';
$this->vista->cache_dir = '/usr/local/apache2/htdocs/smarty/cache';
$this->load_all_blocks();
$this->vista->display('index.tpl');
}
private function RemoveExtension($strName)
{ $ext = strrchr($strName,'.');
$strName = substr($strName, 0, -strlen($ext));
return $strName;}
private function factory($type) {
$classname = $type;
$operation=$_GET['operazione'];
$modules=$_GET['modules'];
return new $classname($modules,$operation);
}
private function load_all_blocks() {
if($handle=@opendir('./modules')){
while(false!==($file=readdir($handle))) {
$type=$this->RemoveExtension($file);
if($file!==".." & $file!==".") {
include_once "./modules/$type.blocks";
$classname = $this->factory($type);
if (method_exists($classname,'operation')) {
$this->vista->assign($type.'operation',$classname->operation());
}
if(method_exists($classname,"output")) {
$this->vista->assign($type,$classname->output());
}
}}}}
}
?>
facendo presente che i vari path sono corretti il risultato è il seguente:
Warning: controller::load_all_blocks(./modules/.blocks) [function.load-all-blocks]: failed to open stream: No such file or directory in /usr/local/apache2/htdocs/includes/controller.php on line 35
Warning: controller::load_all_blocks() [function.include]: Failed opening './modules/.blocks' for inclusion (include_path='.:/usr/share/php:/usr/share/php/Smarty-2.6.11/libs') in /usr/local/apache2/htdocs/includes/controller.php on line 35
Fatal error: Class '' not found in /usr/local/apache2/htdocs/includes/controller.php on line 27
Dove sbaglio?