Php I';对未定义函数的错误调用

Php I';对未定义函数的错误调用,php,undefined,Php,Undefined,嗨,我是php新手,测试了一些代码,我发现一个未定义函数的错误 只需在创建函数后进行回显 首先创建函数test\u input(),然后在声明/定义后使用它 <!DOCTYPE html> <html> <head> </head> <body> <form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">

嗨,我是php新手,测试了一些代码,我发现一个未定义函数的错误



只需在创建函数后进行回显

首先创建函数
test\u input()
,然后在声明/定义后使用它

<!DOCTYPE html>
<html>
<head>
</head>
<body>

<form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
    <input type="text" placeholder="type your full name" name="fullname">
    <input type="submit" name="submit" value="submit">
</form>

<?php
    $getName = "" ;
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
         function test_input($data) {
          $data = trim($data);
          $data = stripslashes($data);
          $data = htmlspecialchars($data);
          return $data;
     }
        $getName = "hello ".test_input($_POST['fullname']);  //Fatal error: Call to undefined function test_input() in C:\xampp\htdocs\ctPHP.php on line 15


    } 
    echo $getName;
?>

</body>
</html>


你有什么错误?请在代码上方加上
以突出显示。