Ho incluso le due classi in avvia.php.
Comunque ora funziona ma il problema è questo:
Fatal error: Using $this when not in object context in C:\wamp\www\test\post.php on line 5
avvia.php:
Codice PHP:
<?php
error_reporting(1);
function __autoload($classname){
require_once $classname.'.php';
}
$content=new content('post', 'viewall');
content.php:
Codice PHP:
<?php
class content{
protected $_app;
protected $_action;
protected $_argument;
function __construct($app, $action, $argument=array()){
$this->_app=$app;
$this->_action=$action;
$this->_argument=$argument;
}
function set($name, $value){
$this->_argument[$name]=$value;
echo $name;
}
function __destruct(){
if(method_exists($this->_app, $this->_action)){
extract($this->_argument, EXTR_PREFIX_SAME, "argument");
call_user_func_array(array($this->_app, $this->_action), $this->_argument);
require_once ROOT.DS.'app'.DS.$this->_app.DS.$this->_action.'.php';
}else{
echo "404";
}
}
}
post.php:
Codice PHP:
<?php
class post extends content{
function viewall(){
$this->set('prova', 'azunyan!');
}
}
Ho aggiornato il codice.