Home  >  Article  >  Backend Development  >  PHP study notes: Function declaration (2)_PHP tutorial

PHP study notes: Function declaration (2)_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:28:43747browse

Copy code The code is as follows:

/*
* 1. Internal functions: PHP can be The purpose of declaring the function
* inside the function is to call
* inside the function to help the external function complete some sub-functions
*
* 2. Recursive function: call your own function name within yourself
*
* 3. Reuse functions
*
* require: for static inclusion
* include: for dynamic inclusion
* require_once: for static inclusion, only included once
* include_once: used for dynamic inclusion, only included once
*
* 4. Use of some system functions
* resource = opendir ("directory name")
* readdir (resource)
*
*
*/
//Internal function
function score($php,$java,$dotnet)
{
function php($php)
{
if($php>60)
return "pass";
else
return "fail";
}
function java($java)
{
if($java>60)
return "pass";
else
return "fail";
}
function dotnet($dotnet)
{
if($dotnet>60)
return "pass";
else
return "fail";
}
$total=$php+$java+$dotnet;
$agv =$total/3;
echo "Your php score is {$php} points,".php($php)."
";
echo "Your java score is {$java } points, ".java($java)."
";
echo "Your dotnet score is {$dotnet} points,".dotnet($dotnet)."
";
echo "Your total score is: {$total}
";
echo "Your average score is: {$agv}
";
}
score( 50,90,70);
//Recursive function
function demo($num)
{
echo $num."
";
if($num>0 )
demo($num-1);
else
echo "-------------------------------- ---
";
echo $num."
";
}
demo(10);
function total($dirname,&$dirnum,&$ filename)
{
$dir=opendir($dirname);
readdir($dir)."
";
readdir($dir)."
";
while($filename=readdir($dir))
{
$newfile=$dirname."/".$filename;
echo $filename."
";
if(is_dir($filename
}
}
$dirnum=0;
$filenum=0;
total("c:/windows",$dirnum,$filenum);
echo "Total number of directories: ".$dirnum."
";
echo "Total number of files: ".$filenum."
";
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323566.htmlTechArticleCopy the code as follows: ?php /* * 1. Internal function: PHP can declare functions inside the function* The purpose is to call* within the function to help the external function complete some sub-functions*...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn