<tfoot id='eoh0P'></tfoot>

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

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

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

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

        奇怪的回声,PHP 中的打印行为?

        时间:2023-10-04

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

            <tfoot id='P9cqs'></tfoot>
          1. <i id='P9cqs'><tr id='P9cqs'><dt id='P9cqs'><q id='P9cqs'><span id='P9cqs'><b id='P9cqs'><form id='P9cqs'><ins id='P9cqs'></ins><ul id='P9cqs'></ul><sub id='P9cqs'></sub></form><legend id='P9cqs'></legend><bdo id='P9cqs'><pre id='P9cqs'><center id='P9cqs'></center></pre></bdo></b><th id='P9cqs'></th></span></q></dt></tr></i><div id='P9cqs'><tfoot id='P9cqs'></tfoot><dl id='P9cqs'><fieldset id='P9cqs'></fieldset></dl></div>
                • <bdo id='P9cqs'></bdo><ul id='P9cqs'></ul>
                    <tbody id='P9cqs'></tbody>
                  <legend id='P9cqs'><style id='P9cqs'><dir id='P9cqs'><q id='P9cqs'></q></dir></style></legend>
                  本文介绍了奇怪的回声,PHP 中的打印行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  下面的代码输出43211,为什么?

                  The following code outputs 43211, why?

                    echo print('3').'2'.print('4');
                  

                  推荐答案

                  您的语句将解析为人类,如下所示.

                  Your statement parses to humans as follows.

                  回显由以下组成的连接字符串:

                  Echo a concatenated string composed of:

                  1. 函数print('3')的结果,返回true,字符串化为1
                  2. 字符串'2'
                  3. 函数print('4')的结果,返回true,字符串化为1
                  1. The result of the function print('3'), which will return true, which gets stringified to 1
                  2. The string '2'
                  3. The result of the function print('4'), which will return true, which gets stringified to 1

                  现在,这里的操作顺序真的很有趣,根本不能以43211结尾!让我们尝试一个变体来找出问题所在.

                  Now, the order of operations is really funny here, that can't end up with 43211 at all! Let's try a variant to figure out what's going wrong.

                  echo '1' . print('2') . '3' . print('4') . '5';
                  

                  这产生 4523111

                  PHP 将其解析为:

                  echo '1' . (print('2' . '3')) . (print('4' . '5'));
                  

                  宾果游戏!左边的 print 首先被评估,打印 '45',这给我们留下了

                  Bingo! The print on the left get evaluated first, printing '45', which leaves us

                  echo '1' . (print('2' . '3')) . '1';
                  

                  然后左边的 print 被计算,所以我们现在打印了 '4523',剩下

                  Then the left print gets evaluated, so we've now printed '4523', leaving us with

                  echo '1' . '1' . '1';
                  

                  成功.4523111.

                  让我们分解一下你对怪异的陈述.

                  Let's break down your statement of weirdness.

                  echo print('3') . '2' . print('4');
                  

                  这将首先打印 '4',留给我们

                  This will print the '4' first, leaving us with

                  echo print('3' . '2' . '1');
                  

                  然后计算下一个打印语句,这意味着我们现在已经打印了'4321',剩下

                  Then the next print statement is evaluated, which means we've now printed '4321', leaving us with

                  echo '1';
                  

                  因此,43211.

                  我强烈建议不要回显print的结果,也不要print的结果回声.这样做是非常荒谬的.

                  I would highly suggest not echoing the result of a print, nor printing the results of an echo. Doing so is highly nonsensical to begin with.

                  经过进一步审查,我实际上并不完全确定 PHP 如何解析这些废话中的任何一个.我不会再去想它了,它会伤到我的大脑.

                  Upon further review, I'm actually not entirely sure how PHP is parsing either of these bits of nonsense. I'm not going to think about it any further, it hurts my brain.

                  这篇关于奇怪的回声,PHP 中的打印行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:无法运行 PHP cron 脚本 下一篇:从 PHP 打印到 POS 打印机

                  相关文章

                  最新文章

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

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

                      <tfoot id='Qeb4R'></tfoot>

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