1. <small id='SpysA'></small><noframes id='SpysA'>

  2. <i id='SpysA'><tr id='SpysA'><dt id='SpysA'><q id='SpysA'><span id='SpysA'><b id='SpysA'><form id='SpysA'><ins id='SpysA'></ins><ul id='SpysA'></ul><sub id='SpysA'></sub></form><legend id='SpysA'></legend><bdo id='SpysA'><pre id='SpysA'><center id='SpysA'></center></pre></bdo></b><th id='SpysA'></th></span></q></dt></tr></i><div id='SpysA'><tfoot id='SpysA'></tfoot><dl id='SpysA'><fieldset id='SpysA'></fieldset></dl></div>

      <bdo id='SpysA'></bdo><ul id='SpysA'></ul>
      <tfoot id='SpysA'></tfoot>

      <legend id='SpysA'><style id='SpysA'><dir id='SpysA'><q id='SpysA'></q></dir></style></legend>

      Symfony/Doctrine:反序列化在行动与模板

      Symfony/Doctrine: Unserialize in action vs template(Symfony/Doctrine:反序列化在行动与模板)
    1. <legend id='95Dfl'><style id='95Dfl'><dir id='95Dfl'><q id='95Dfl'></q></dir></style></legend>

      <tfoot id='95Dfl'></tfoot>

      <small id='95Dfl'></small><noframes id='95Dfl'>

      • <bdo id='95Dfl'></bdo><ul id='95Dfl'></ul>

              <i id='95Dfl'><tr id='95Dfl'><dt id='95Dfl'><q id='95Dfl'><span id='95Dfl'><b id='95Dfl'><form id='95Dfl'><ins id='95Dfl'></ins><ul id='95Dfl'></ul><sub id='95Dfl'></sub></form><legend id='95Dfl'></legend><bdo id='95Dfl'><pre id='95Dfl'><center id='95Dfl'></center></pre></bdo></b><th id='95Dfl'></th></span></q></dt></tr></i><div id='95Dfl'><tfoot id='95Dfl'></tfoot><dl id='95Dfl'><fieldset id='95Dfl'></fieldset></dl></div>
                <tbody id='95Dfl'></tbody>

              1. 本文介绍了Symfony/Doctrine:反序列化在行动与模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                谁能告诉我为什么调用反序列化"在操作中可以正常工作,但在模板中会出现偏移错误?

                Can anyone tell me why calling "unserialize" works fine in an action but gives an offset error in a template?

                基本上可以将数据库文本结果反序列化为操作中的变量并将其传递给模板,在这种情况下它可以正常显示:

                It's basically possible to unserialize a database text result into a variable in an action and pass it to template, in which case it displays fine:

                $this->clean = unserialize($this->raw);
                <?php echo $clean ?>
                

                但如果直接在模板中调用则不会:

                But not if called directly in a template:

                <?php echo unserialize($raw) ?>
                

                想知道为什么会这样以及是否有一些解决方法.

                Would be interested in knowing why this is so and whether there's some workaround.

                谢谢.

                推荐答案

                Symfony 将所有模板变量放入一个 sfOutputEscaperArrayDecorator 类.所以当你编写 unserialize($var) 时,实际上是在尝试对 sfOutputEscaperArrayDecorator 类进行反序列化.

                Symfony puts all template variables into a sfOutputEscaperArrayDecorator class. So when you write unserialize($var), you are actually trying to unserialize the sfOutputEscaperArrayDecorator class.

                我建议在 settings.yml 中关闭输出转义:

                I recommend turning off output escaping in settings.yml:

                escaping_strategy:     false
                

                这是 Symfony 中一个愚蠢的、破坏性能的、不必要的功能,需要被扼杀.

                It is a stupid, performance-slaughtering, unnecessary feature of Symfony that needs murdered.

                更新:

                如果您关闭 escaping_strategy,您将需要使用 htmlSpecialCharacters() 手动转义用户的输入(以防止 XSS).

                If you turn off escaping_strategy, you will need to manually escape input from the users (to prevent XSS) with htmlSpecialCharacters().

                Symfony 类会为您做到这一点,但这意味着它还会转义每一个数字和字符——您已经知道其中 99% 是安全的(ID、日期、您自己的内容).当我关闭自动转义时,我的服务器负载明显下降.

                The Symfony class does that for you, but that means it also escapes every single number and character -- 99% of which you already know will be safe (IDs, dates, your own content). When I turned off the automatic escaping, my server load fell significantly.

                请记住,如果您将 sfOutputEscaperArrayDecorator 传递给部分,Symfony 双重应用这种自动转义,这意味着 > 将变为 <代码>&amp;gt;

                Keep in mind that Symfony double-applies this automatic escaping if you pass a sfOutputEscaperArrayDecorator to a partial, meaning > will become &amp;gt;

                这篇关于Symfony/Doctrine:反序列化在行动与模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  <tbody id='zjkOs'></tbody>

                  <tfoot id='zjkOs'></tfoot>
                • <legend id='zjkOs'><style id='zjkOs'><dir id='zjkOs'><q id='zjkOs'></q></dir></style></legend>
                  <i id='zjkOs'><tr id='zjkOs'><dt id='zjkOs'><q id='zjkOs'><span id='zjkOs'><b id='zjkOs'><form id='zjkOs'><ins id='zjkOs'></ins><ul id='zjkOs'></ul><sub id='zjkOs'></sub></form><legend id='zjkOs'></legend><bdo id='zjkOs'><pre id='zjkOs'><center id='zjkOs'></center></pre></bdo></b><th id='zjkOs'></th></span></q></dt></tr></i><div id='zjkOs'><tfoot id='zjkOs'></tfoot><dl id='zjkOs'><fieldset id='zjkOs'></fieldset></dl></div>

                    <small id='zjkOs'></small><noframes id='zjkOs'>

                      • <bdo id='zjkOs'></bdo><ul id='zjkOs'></ul>