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

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

      1. PHP 开放标签“&lt;?="和“&lt;?php"/“&lt;?&quo

        What is the difference between the PHP open tags “lt;?=” and “lt;?php”/“lt;?”?(PHP 开放标签“lt;?=和“lt;?php/“lt;?之间有什么区别?)

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

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

                • <tfoot id='X6IyI'></tfoot>
                    <tbody id='X6IyI'></tbody>
                  <legend id='X6IyI'><style id='X6IyI'><dir id='X6IyI'><q id='X6IyI'></q></dir></style></legend>

                  本文介绍了PHP 开放标签“&lt;?="和“&lt;?php"/“&lt;?"之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  抱歉这个愚蠢的问题,但我遇到了使用的代码:

                  printOnLoad();?><?=$MAP_OBJECT->printMap();?><?=$MAP_OBJECT->printSidebar();?>

                  <?= 相比有什么特别之处,或者只是简单的 <??

                  解决方案

                  而不是谈论是否short_open_tags 是否已弃用我们应该谈谈使用短开放标签时的优缺点:

                  优势

                  使用短的开始标签 <?<?= 比标准的开始标签 <?php 更短并且可能更容易编写 分别.在模板中直接使用 PHP 时,这非常方便.(这可能也是 PHP 具有控制结构的替代语法的原因.)>

                  缺点

                  需要特定的配置

                  使用短开放标签时,您需要启用short_open_tags.如果您或您的网络托管服务提供商决定禁用 short_open_tags,您的应用程序可能无法再运行,并且您可能会遇到一些严重的安全问题.因为如果 short_open_tags 被禁用,只有标准的开始标签 被识别,并且短开始标签内的所有内容都被视为纯文本.(另请参阅 Sarfraz Ahmed 引用的博客文章回答.)

                  如果您的目标是编写不适合您的应用程序,则此要求会降低您的 PHP 应用程序的可移植性.这也是为什么许多人建议不要使用短的开放标签(包括 PHP 手册)的原因:

                  <块引用>

                  注意:在开发用于重新分发或部署在不受您控制的 PHP 服务器上的应用程序或库时,应避免使用短标签,因为短标签可能不受支持目标服务器.对于可移植、可再分发的代码,请确保不要使用短标签.

                  从 PHP 5.4 开始, 始终可用,无论 short_open_tags 选项如何. 另一方面,需要启用该选项.

                  与 XML 处理指令冲突

                  另一个问题是在使用 XML 处理指令(例如 <)时;?xml ... ?>.当启用 short_open_tags 时,您不能直接在代码中使用它们,而需要使用 PHP 来输出它:

                  <块引用>

                  如果您想将 PHP 与 XML 结合使用,您可以禁用此选项以使用 内联.否则,可以用PHP打印,例如: ';?>.

                  否则 PHP 会阻塞在 中的 xml.

                  关于弃用的最后一句话:目前 short_open_tags 未弃用.否则手册会明确说明这一点.此外,PHP 的发明者 Rasmus Lerdorf 在回复中写道问题short_open_tag 在 PHP 6 中被弃用是真的吗?"在内部邮件列表上,有几个原因不删除 PHP 6 中的short_open_tags:

                  <块引用>

                  这是我们决定不在 PHP 6 中删除它们的原因之一.

                  Sorry for the silly question, but I ran across code that used:

                  <?=$MAP_OBJECT->printOnLoad();?>
                  <?=$MAP_OBJECT->printMap();?>
                  <?=$MAP_OBJECT->printSidebar();?>
                  

                  Is there anything special about <?= over <?php or just plain <??

                  解决方案

                  Rather than talking about whether short_open_tags is deprecated or not we should talk about the advantages and disadvantages when using short open tags:

                  Advantages

                  Using the short open tags <? along with <?= is shorter and probably easier to write than the standard opening tags <?php and <?php echo respectively. That’s quite handy when using PHP directly in a template. (That’s probably also the reason why PHP has an alternative syntax for control structures.)

                  Disadvantages

                  Requires a specific configuration

                  When using short open tags you are required to have short_open_tags enabled. If you or your web hosting provider decides to disable short_open_tags, your application probably won’t work any more and you can have some serious security issues. Because if short_open_tags is disabled, only the standard opening tags <?php are recognized and everything inside short opening tags is treated as plain text. (See also the blog post referenced in Sarfraz Ahmed’s answer.)

                  This requirement makes your PHP application less portable if you aim to write applications that are not just for you. That’a also why many recommend not to use short open tags (including the PHP manual):

                  Note: Using short tags should be avoided when developing applications or libraries that are meant for redistribution, or deployment on PHP servers which are not under your control, because short tags may not be supported on the target server. For portable, redistributable code, be sure not to use short tags.

                  As of PHP 5.4 <?= is always available, regardless of the short_open_tags option. <? on the other hand requires the option to be enabled.

                  Conflicts with XML processing instructions

                  Another issue is when using XML processing instructions like <?xml … ?>. When short_open_tags is enabled you cannot use them directly in your code but need to use PHP to output it:

                  If you want to use PHP in combination with XML, you can disable this option in order to use <?xml ?> inline. Otherwise, you can print it with PHP, for example: <?php echo '<?xml version="1.0"?>'; ?>.

                  Otherwise PHP will choke on the xml in <?xml.

                  Now some last words about the deprecation: Currently short_open_tags is not deprecated. Otherwise the manual would state that explicitly. Additionally, Rasmus Lerdorf, inventor of PHP, wrote in a reply on the question "Is it true that short_open_tag is deprecated in PHP 6?" on the internals mailing list that there were several reasons not to remove short_open_tags in PHP 6:

                  Which is one of the reasons we decided not to remove them in PHP 6.

                  这篇关于PHP 开放标签“&lt;?="和“&lt;?php"/“&lt;?"之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  How do I pass parameters into a PHP script through a webpage?(如何通过网页将参数传递给 PHP 脚本?)
                  PHP - include a php file and also send query parameters(PHP - 包含一个 php 文件并发送查询参数)
                  Where can I read about conditionals done with quot;?quot; and quot;:quot; (colon)?(我在哪里可以阅读有关使用“?完成的条件的信息?和“:(冒号)?)
                  Accessing arrays whitout quoting the key(在不引用键的情况下访问数组)
                  What is the name for the quot;lt;lt;lt;quot; operator?(“lt;lt;lt;的名字是什么?操作员?)
                  default as first option in switch statement?(默认为 switch 语句中的第一个选项?)

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

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

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