• <small id='uKC6p'></small><noframes id='uKC6p'>

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

      <bdo id='uKC6p'></bdo><ul id='uKC6p'></ul>

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

      1. 在 PHP 中使用来自另一个条件的变量

        Using a variable from another condition in PHP(在 PHP 中使用来自另一个条件的变量)
          <tbody id='qnkgw'></tbody>

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

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

              <tfoot id='qnkgw'></tfoot>
              • <bdo id='qnkgw'></bdo><ul id='qnkgw'></ul>
                  <legend id='qnkgw'><style id='qnkgw'><dir id='qnkgw'><q id='qnkgw'></q></dir></style></legend>
                  本文介绍了在 PHP 中使用来自另一个条件的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有这个代码:

                  if(!isset($_GET["act"]))
                  {
                      $display->display("templates/install_main.html");
                      if(isset($_POST["proceed"]))
                      {
                          $prefix = $_POST["prefix"];
                      }
                  }
                  
                  if($_GET["act"] == "act")
                  {
                      echo $prefix;
                  }
                  

                  基本上我之前提出过类似的问题,问题是,如何使变量可访问?请提及是否有任何方法可以做到这一点,即使改变了它的完成方式(有人告诉我可以使用课程,但不太确定如何完成),或任何其他使其可访问的方式.

                  Basically I've made a similar question before, thing is, HOW can I make the variable accessible? please mention if there is any way to do so, even with changing the way it's done (someone told me it's possible with a class but not quite sure how it can be done), or any other way to make it accessible.

                  谢谢!

                  推荐答案

                  PHP 的变量作用域是函数级的.$prefix 将在您的第二个 if() IF 中可用,另一个 if() 评估为真并实际执行了 $prefix = ... 代码.

                  PHP's variable scope is function-level. $prefix would be available in your second if() IF the other if()'s evaluated to true and actually executed that $prefix = ... code.

                  例如

                  if (true) {
                      $foo = 'bar'; // always executes
                  }
                  if (false) {
                      $baz = 'qux'; // never executes
                  }
                  echo $foo; // works just fine
                  echo $baz; // undefined variable, because $baz='qux' never executed.
                  

                  另请注意,PHP 不能进行时间旅行:

                  Also note that PHP is not capable of time travel:

                  echo $x; // undefined variable;
                  $x = 'y';
                  echo $y; // spits out 'y'
                  

                  较早"的代码不会有较晚的"变量可用,因为实际创建/分配值给这些变量的代码还没有执行.

                  "earlier" code will not have "later" variables available, because the code that actually creates/assigns values to those variables won't have executed yet.

                  这篇关于在 PHP 中使用来自另一个条件的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)

                  <tfoot id='20hMy'></tfoot>
                      <tbody id='20hMy'></tbody>
                      <bdo id='20hMy'></bdo><ul id='20hMy'></ul>

                          <small id='20hMy'></small><noframes id='20hMy'>

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