I would like to call a function within a class method, I created this script but not work as I can do?
Fatal error: Call to a member function function2() on null in /.../.../index.php on line 12
public static function table($name_t, callable $callback){
self::databaseConnection();
try {
$matches = array(
.....
);
function engine($var){
Gaia::$engine__ = $var[0];
}
$eng = new Table_call;
echo $eng;
$callback($matches);
if(isset(self::$s)){
//self::$instance->exec("CREATE TABLE IF NOT EXISTS ".$name_t."( ".trim(self::$s,',')." ) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
echo "Dump Success!<br> ".self::$engine__ ;
}
//return $bgj;
} catch (Exception $e) {
self::$instance = null;
echo ("Oh noes! There's an error in the query: ". $e);
}
}
Class File 2
class Table_call extends Gaia{
public function __call($name,$arg){
call_user_func($name,$arg);
}
}
Index File
Gaia::table('test', function($table){
$table['autoIncrement']('id');
})->engine('MyISAM');
how can i add function this way ??
" ->function2('hello') "?