Php Fatal Error: Call To Undefined Function Test_input() In C:\wamp\www\web\new9.php On Line 11
Solution 1:
Move your function out of your conditional if
statement
It should be like this...
<?php// define variables and set to empty values$name1Err = $email1Err = "";
$name1 = $email1 = "";
// Moved herefunctiontest_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return$data;
}
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
// .... your remaining code .......... !
From the PHP Docs...
When a function is defined in a conditional manner ... Its definition must be processed prior to being called.
Solution 2:
In general, functions are parsed first and can therefore be used in any order.
echo foo();
function foo() {return"bar";}
The above works fine.
However, unlike some languages like JavaScript, PHP allows you to conditionally define functions. You might do something like this:
if( $something) {
functionfoo() {echo"bar";}
}
else {
functionfoo() {echo"fish";}
}
foo();
It's a bad thing to do (personally I'd prefer anonymous functions, or putting the conditional inside the function), but it's allowed.
However, doing this means that the functions can no longer be grabbed. They MUST be defined before they can be used. Going back to our first example:
if( true) {
echo foo();
function foo() {return"bar";}
}
This will fail.
Solution 3:
try
<formmethod='post'enctype='multipart/form-data'action='<?phpecho htmlspecialchars($_SERVER["PHP_SELF"]);?>'>
source:w3schools
Post a Comment for "Php Fatal Error: Call To Undefined Function Test_input() In C:\wamp\www\web\new9.php On Line 11"