【问题标题】:php 5.3.2 - $_get $_post is not working [closed]php 5.3.2 - $_get $_post 不工作 [关闭]
【发布时间】:2012-10-11 11:52:15
【问题描述】:

我在我的本地主机上运行一个支持 php 和 mysql 的 apache 服务器。唯一的问题是,$_GET$_POST 根本不起作用。

这是我的 html 文件:

<html>
<body>
<form action="message.php" method="GET">
Enter your message here: <input type="text" name="msg" size="30">
<input type="submit" value="Send">
</form>
</body>
</html>

这是我的 message.php 文件:

<?php
$input = $_GET('msg');
echo "$input";
?>

如果我在 html 的文本输入字段中键入“blablabla”,它会将我重定向到 [localhost]/message.php?msg=blablabla,这很好,但 php 给了我一个空白页面。 我查看了 [localhost]/message.php?msg=blablabla 的源代码,但它只有一个空的部分和一个空的部分。

是我犯了什么错误还是这是一个错误?

【问题讨论】:

  • 始终将error_reporting 设置为E_ALL 有助于解决问题。

标签: php apache post get localhost


【解决方案1】:

如果你想在数组中测试结果来使用,

print_r($_POST); //method post
print_r($_GET); //method get
print_r($_SERVER); //all variable server

方法 POST 和 GET 不起作用,那个变量数组所以你不能使用 () 而是 $bla[]。

echo $_GET['msg'];

【讨论】:

    【解决方案2】:
    $input = $_GET('msg');
    

    $input = $_GET['msg'];
    

    【讨论】:

      【解决方案3】:

      您以错误的方式使用$_GET$_GET 是一个数组。所以你必须这样使用它:

      $_GET['msg'];
      

      【讨论】:

        猜你喜欢
        • 2014-12-12
        • 2013-03-01
        • 1970-01-01
        • 1970-01-01
        • 2016-11-26
        • 1970-01-01
        • 1970-01-01
        • 2023-03-16
        • 2012-05-10
        相关资源
        最近更新 更多