Are function prototypes alowed in PHP? If I call a user defined function above the definition I get an undefined function. If I place the function definition before I call it this problem is solved. In C/C++ we would put the prototypes in a header file, #include it, then we can put our definitions anywhere and call them from anywhere.
So I made my own prototype, and user defined function:
$string = $_POST['string'];
int check_length(string, int); // prototype
echo "<br>".check_length($string); // call it
function check_length($string, $max){ // user defined
echo "it is ".strlen($string)." characters long!";
if (strlen($string) > $max)
return false;
else return true;
}
An error is returned parse error, unexpected T_STRING the line it points to is my prototype. So seems it dont recognize my prototype or does not expect to see it.
Can someone help me with this.
I dont want to place the definition before I call it each time, thats messy, especialy if one functions calling another which calls the origional and so fourth...
Sugestions?