public function TwigExtension::phpFilter in Twig Tweak 8
Same name and namespace in other branches
- 8.2 src/TwigExtension.php \Drupal\twig_tweak\TwigExtension::phpFilter()
Evaluates a string of PHP code.
Parameters
string $code: Valid PHP code to be evaluated.
Return value
mixed The eval() result.
File
- src/
TwigExtension.php, line 503
Class
- TwigExtension
- Twig extension with some useful functions and filters.
Namespace
Drupal\twig_tweakCode
public function phpFilter($code) {
ob_start();
// @codingStandardsIgnoreStart
print eval($code);
// @codingStandardsIgnoreEnd
$output = ob_get_contents();
ob_end_clean();
return $output;
}