A function declaration of PHP Learning Notes (ii) _php tutorial

Source: Internet
Author: User
Tags dotnet
Copy CodeThe code is as follows:
/*
* 1. Intrinsic functions: PHP can declare functions inside a 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 within yourself
*
* 3. Reusing functions
*
* Require: for static inclusion
* Include: for dynamic inclusion
* Require_once: For static inclusion, including only once
* Include_once: For dynamic inclusion, including only once
*
* 4. Use of some system functions
* Resource =opendir ("directory Name")
* READDIR (Resources)
*
*
*/
Intrinsic functions
Function score ($php, $java, $dotnet)
{
function php ($php)
{
if ($php >60)
return "Pass";
Else
Return "Failed";
}
function Java ($java)
{
if ($java >60)
return "Pass";
Else
Return "Failed";
}
function dotnet ($dotnet)
{
if ($dotnet >60)
return "Pass";
Else
Return "Failed";
}
$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},". dotnet ($dotnet). "
";
echo "Your total score is: {$total}
";
echo "Your average score is: {$AGV}
";
}
Score (50,90,70);
Recursive functions
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 directory:". $dirnum. "
";
echo "Total Files:". $filenum. "
";
?>

http://www.bkjia.com/PHPjc/323566.html www.bkjia.com true http://www.bkjia.com/PHPjc/323566.html techarticle Copy the code as follows:? PHP/* * 1. Intrinsics: PHP can declare functions inside functions * The purpose is to call inside the function * to help external functions to complete some sub-functions * ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.