PHP,使用$ _GET时出错[' pFullName'];?

时间:2016-05-17 11:52:13

标签: php get

当我试图回应玩家的名字时,我发现致命错误。

我对PHP仍然很陌生,这可能是一个新手的错误,但我已经尝试了所有。

这是我的代码:



<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>A1S | e-tracker</title>
        <link rel="stylesheet" href="css/menu.css">
        <link rel="author" href="humans.txt">
    </head>
    <body>

        <form action="#" method="get">
            Name: <input type="text" placeholder="Player Full Name" name="pFullname"><br>
            Date of Birth: <input type="date" name="pDob"><br>
            Weight: <input type="number" name="pWeight" placeholder="Pounds" min="0"><br>
            Height: <input type="number" name="pHeight" placeholder="Centimeters" min="0"><br>
            <input type="submit">

            <?php
            $playerName = $_GET['pFullName'];
              echo $playerName;
             ?>
        </form>
        
        <script src="script.js"></script>
    </body>
</html>
&#13;
&#13;
&#13;

非常感谢任何帮助,谢谢!

2 个答案:

答案 0 :(得分:3)

使用以下代码:

LaunchScreen.storyboard

答案 1 :(得分:0)

另一种解决方案(如果您使用的是PHP7):

<?php
$playerName = $_GET['pFullname']??'';
echo $playerName;

?? - Null coalescing operator

  

对于需要与isset()一起使用三元组的常见情况,添加了空合并运算符(??)作为语法糖。它返回第一个操作数(如果存在且不为NULL);否则它返回第二个操作数。

所以它相当于

$playerName = isset($_GET['pFullname']) ? $_GET['pFullname'] : '';

注意: 您使用pFullName代替pFullname。后者是控件名称