user1950896 user1950896 -4 years ago 124
PHP Question

Twig ignore Array to string conversion exception

Any way to ignore Array to string conversion exception?

$twig = new Twig_Environment($loader, [
'strict_variables' => false,
'debug' => false,
]);


I'am allowing external users to edit their custom html. When saving
{{ somearray }}
is a valid syntax

Answer Source

That message is not done by twig, but by php itself, you can see if you try to echo an array.

You should not display such messages in production, an important part of setting up a prod server is making sure display_errors is off so the user cannot see implementation details of your site.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download