开发者

How symfony auto clean the HTML output?

开发者 https://www.devze.com 2023-03-22 06:45 出处:网络
I know it must use htmlspecialchars() but it automatic clean the output when I use echo statement. Manually, without symfony, how can I do that? Override echo statement? I know theres ob_start(), ob_g

I know it must use htmlspecialchars() but it automatic clean the output when I use echo statement. Manually, without symfony, how can I do that? Override echo statement? I know theres ob_start(), ob_get_contents() etc, but it then clean the 开发者_如何学JAVAwhole output


There's a method for outputting data in the template that bypasses the output escaping:

<?php echo $sf_data->getRaw('variable_name_here'); ?>

I think you can even output the entire template content for specific layouts using:

<?php echo $sf_data->getRaw('sf_content') ?>

The escaping settings for your app are controlled in settings.yml (all_settings_escaping_method). You should see ESC_SPECIALCHARS on by default.

Also, using...

<?php echo html_entity_decode($variable) ?>

... can help sometimes.

0

精彩评论

暂无评论...
验证码 换一张
取 消