20160408-php Process Control and functions

Source: Internet
Author: User

Process Control:

I. Branching structure

If...elseif...elseif...elseswitch...case...break

Two. Cycle control

For

While


Three. Abort the loop

End this layer loop

Break


End this cycle

Continue


Four. Abort the script

    1. Exit ();

    2. Die ();



Function:

Language structure

Custom functions

Parameters

Default parameters

function return value

Variable number of parameters

Variable function

Variable scope

Reference parameters

callback function

static variables

file contains

Recursive functions


Function Classification:

    1. Custom functions

    2. callback function

    3. Variable function

    4. Recursive functions


Language structure:

if ()

for ()

while ()

Switch ()


Echo ()

Print ()


Array ()

List ()

foreach ()


Isset ()

Unset ()

Empty ()


Exit ()

Die ()


Include ()

Require ()


Custom functions:

function Fun () {}

Call Function:

Fun ();


Parameters:

Fun (3, "red");


Default parameters:

Function Show ($num =9, $color = "Red") {echo $num; Echo $color; } The result of the function: 1. Output 2. Returns the result variable number of parameters: 1.func_get_args ();  2.func_num_args (); Variable function: $a = "sum";  $a (); Variable scope: 1. Variables outside the global variables function are global variables 2. Variables inside a local variable function are local variables the Global keyword is modified to make the local variable reference parameter: 1. The inside and outside of the function points to the address of the same variable, changing the value of the variable inside the function,  Outside of the function, the callback function is also changed: the parameter of 1 function is the name of another function, then this parameter is called the callback function; Static variables: Multiple calls to the same function, static variables can be tracked down

The file contains:

    1. Include () contains an error script to continue execution

    2. Require () If the error file aborts execution


Recursive functions:

function to call this function, from top to bottom to see the code

This article is from the "Gavin" blog, make sure to keep this source http://gavinsw.blog.51cto.com/3097149/1761680

20160408-php Process Control and 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.