Copy Code code as follows:
<?php
/*
* 1. Internal function: PHP can declare function inside function
* The purpose is to call inside the function
* Used to help external functions complete some sub functions
*
* 2. Recursive function: Call your own function name inside yourself
*
* 3. Reusing functions
*
* Require: for static inclusion
* Include: for dynamic inclusion
* Require_once: For static inclusion, contains only once
* Include_once: For dynamic inclusion, containing only once
*
* 4. Use of some system functions
* Resource =opendir ("directory Name")
* READDIR (Resources)
*
*
*/
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). " <br> ";
echo "Your Java score is {$java} points,". Java ($java). " <br> ";
echo "Your dotnet score is {$dotnet} points,". dotnet ($dotnet). " <br> ";
echo "Your total score is: {$total}<br>";
echo "Your average score is: {$AGV}<br>";
}
Score (50,90,70);
Recursive functions
Function Demo ($num)
{
echo $num. " <br> ";
if ($num >0)
Demo ($num-1);
Else
echo "--------------------------------<br>";
echo $num. " <br> ";
}
Demo (10);
function Total ($dirname,& $dirnum,& $filename)
{
$dir =opendir ($dirname);
Readdir ($dir). " <br> ";
Readdir ($dir). " <br> ";
while ($filename =readdir ($dir))
{
$newfile = $dirname. " /". $filename;
echo $filename. " <br> ";
if (Is_dir ($filename
}
}
$dirnum = 0;
$filenum = 0;
Total ("C:/windows", $dirnum, $filenum);
echo "Total directory:". $dirnum. " <br> ";
echo "Total Files:". $filenum. " <br> ";
?>