【问题标题】: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.