Este es mi codigo limpio:
Código PHP:
Ver original<?php
require_once 'Twig/Autoloader.php';
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment
($loader, array( 'cache' => 'cache',
'debug' => 'true'));
$template = $twig->loadTemplate('index.twig.html');
echo $template->render(array( 'variable' => 'Hola mundo!',
));
Asi quedo luego de leer la guia:
Código PHP:
Ver original<?php
require_once 'Twig/Autoloader.php';
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment
($loader, array( 'cache' => 'cache',
'debug' => 'true'));
/*---------------*/
$function = new Twig_SimpleFunction('funciontestmia', function () {
return 'VARIABLE TEST';
});
/*-------------*/
$template = $twig->loadTemplate('index.twig.html');
$twig->addFunction($function); // Agrega la funcion
echo $template->render(array( 'variable' => 'Hola mundo!',
));
El error es el siguiente:
Código PHP:
Ver originalFatal error: Class 'Twig_SimpleFunction' not found in C:\xampp\htdocs\1\index.php on line 12
Osea la clase Twig_SimpleFunction es como si no existiera