【问题标题】:PHP variable Syntax using _GET使用 _GET 的 PHP 变量语法
【发布时间】:2014-03-05 15:36:24
【问题描述】:

我有一个当前重定向到默认页面并且效果很好的redirectURL

  $WA_redirectURL = "mypage.php";

我想插入一个可用但出现语法错误的 _GET 值。这是我正在尝试的。我认为这些句点可以让我将值输入 URL?

  $WA_redirectURL = "mypage.php?EmpNumber=". echo $_GET['EmpNumber'] .";

【问题讨论】:

    标签: php string syntax-error concatenation


    【解决方案1】:

    连接字符串时不要使用echo

    $WA_redirectURL = "mypage.php?EmpNumber=". echo $_GET['EmpNumber'] .";
    

    应该是:

    $WA_redirectURL = "mypage.php?EmpNumber=". $_GET['EmpNumber'];
    

    (最后一个引号也是错误的)。

    【讨论】:

    • 谢谢约翰,第二个问题就像你说的那样!
    【解决方案2】:

    您使用 echo 向用户发送文本。

    如果您想将字符串连接在一起,请使用句点来连接事物。

    例如:

    echo "hello"; // this will print hello to the screen
    
    $testing = "hello "."world!";
    
    echo $testing; // this will print hello world! to the screen.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-15
      • 2019-11-30
      • 1970-01-01
      • 2012-03-30
      • 1970-01-01
      • 1970-01-01
      • 2019-07-25
      • 2011-07-07
      相关资源
      最近更新 更多