The syntax for a function is:
Function definition method
Copy code The code is as follows:
function "function_name" (arg1, arg2...)
{
[code to execute]
return [final_result] ;
}
Copy the code The code is as follows:
function double_this_number($input_number)
{
return $input_number*2;
}
Copy code The code is as follows:
$x = 10;
$y = double_this_number($x);
print $y;
Copy the code The code is as follows:
function safePost($v=0)
{
if( $v==0 )
{
$protected = array("_GET", "_POST", "_SERVER", "_COOKIE", "_FILES", "_ENV", "GLOBALS");
foreach($protected as $var) {
if(isset($_REQUEST[$var]) || isset($_FILES[$var]) )
{
die("Access denied");
}
}
}
}
The above introduces how to use Plants vs. Zombies modifier, how to use PHP functions and how to define functions, including how to use Plants vs. Zombies modifier. I hope it will be helpful to friends who are interested in PHP tutorials.