Php learning notes function declaration (2)

Source: Internet
Author: User

Copy codeThe Code is as follows:
<? Php
/*
* 1. Internal function: PHP can declare the function inside the function.
* The purpose is to call the function internally.
* Used to help external functions complete some sub-functions
*
* 2. recursive functions: call your own function name within yourself.
*
* 3. Reuse Functions
*
* Require: used for static inclusion
* Include: used for dynamic inclusion
* Require_once: used for static inclusion only once
* Include_once: used for dynamic inclusion, only once
*
* 4. Use of some system functions
* Resource = opendir ("directory name ")
* Readdir (Resource)
*
*
*/
// Internal functions
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},". php ($ php). "<br> ";
Echo "your java score is {$ java},". java ($ java). "<br> ";
Echo "Your dotnet score is {$ dotnet},". dotnet ($ dotnet). "<br> ";
Echo "your total score is: {$ total} <br> ";
Echo "your average score is: {$ agv} <br> ";
}
Score (50, 90, 70 );
// Recursive Function
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 number of directories:". $ dirnum. "<br> ";
Echo "Total number of files:". $ filenum. "<br> ";
?>

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.