You may run php code on blade.
PHP code from a table
Hi, Is there any way to get php code from a mysql table, and run it in a blade template?
But I don't know how it have to do.
I don't think you can execute much , here is example you can search something like this:
$x = 'php test.php';
exec($x, $message);
print_r($message);
and can see output using message variable, i didn't tried this with mysql but with file it's working.
Just start writing php syntax like you do on php file. Blade will recognize php code
...
<?php
echo "hello world";
?>
...
It is commented in HTML viewer:
?php echo "hello world"; ? -->Nobody?
@Gun22 It is likely that Blade is escaping the text to prevent unexpected code in the output. Try {!! $output !!} instead of {{ $output }} (where $output is whatever code you are trying to execute). Untested but would make sense to me :)
Hope it helps
Not working, i've got 4.2... Some tips?
With Laravel 4.*, you must use the following syntax to disable escaping in Blade views:
{{{ $output }}}
And the new syntax since Laravel 5+:
{!! $output !!}
You can find more information in the Laravel documentation.
Is there any way to get php code from a mysql table, and run it in a blade template
Possible? Certainly... but this is a VERY bad idea.
Please or to participate in this conversation.