PHP不会回显变量

PHP不会回显变量,php,output,echo,Php,Output,Echo,我有以下非常基本的PHP脚本: <?php $username = $_POST['username']; $password = $_POST['password']; echo "This is the username: "; echo $username; ?> 我的url中有用户名和密码参数。为什么不回显用户名?尝试回显整个$\u POST数组。这可能会导致您遇到问题 echo "<pre>".print_r($_POST,true)."</

我有以下非常基本的PHP脚本:

    <?php
$username = $_POST['username'];
$password = $_POST['password'];

echo "This is the username: ";
echo $username;
?>

我的url中有用户名和密码参数。为什么不回显用户名?

尝试回显整个$\u POST数组。这可能会导致您遇到问题

echo  "<pre>".print_r($_POST,true)."</pre>";

它不会显示,因为URL中的参数被解析为GET而不是POST

使用$\u GET['username']从中获取数据http://www.somesite.com?username=yash

参考资料:


也许他们是路过的?当你发现它们在url中时。使用:$\u GET而不是$\u POST在$\u GET数组中找到通过URL传递的数据,而不是$\u POST。您还可以使用$\u请求访问URL和POST参数。
echo  "<pre>".print_r($_POST,true)."</pre>";