"The Wind horse a clan _php"

Source: Internet
Author: User
Tags arithmetic operators bitwise operators

Review

Operators: Arithmetic operators, logical operators, comparison operators, bitwise operators, assignment operators, string operators, self-action operators, error suppressors, ternary operators

BITS: Binary, original code, anti-code, complement

Process Control: Sequential, branching, looping

Branching structure: If branch and Switch branch

Switch: The last face of each case will be followed by a break

Switch: Suitable for fixed-value processing, not suitable for conditional arithmetic processing

If: suitable for processing of conditional operations

Loop structure: For, while, Do-while, foreach

' Function: System functions and custom functions

Call: Function name (), once the system touches a value followed by parentheses, the system will read the contents of the memory, as a function to execute

Define functions: Function name (formal argument list) {

function Hugh

return value

function MyFunc ($name) {//body}

MyFunc ($name, $age, $sex ...); PHP supports the actual parameters more than the number of formal parameters, redundant parts, the system abandoned the use, and only get the number of formal parameter corresponding to the location

Parameter passing: value passing, reference passing

Value passing: Copies the value of an external variable, assigns a value to the parameter

Reference Pass: Assigns the address of the memory space pointed to by the external variable to the parameter

Function MyFunc (& $name) {//function Body}//Add address character &

MyFunc ($name)//cannot use address symbol &

Scope: global scope and local scope

Global scope: External functions can be used

Local scope: Internal use of functions

External variables are used inside the function: $GLOBALS ("variable name"), global keyword

anonymous functions

You can use a function without naming the function

Question: 1, how to define anonymous functions

2. How to invoke anonymous functions

1<?PHP2     3     //define an anonymous function, assign a function to a variable4     $name=function(){5         return"The wind Horse of a clan";6     };7     8     //Calling anonymous functions9     Echo $name();Ten? >
php--example of using anonymous functions

Method: Use function () {//function body} to define functions

$name = function () {//body}; Assign a function to a variable, and remember to add a semicolon;

$name (); adding parentheses () to a variable is equivalent to letting the system admit that it is a function, not a variable

Variable functions

Custom functions, assign a custom function to a variable, let the variable act as a function alias, so that the variable can be various functions

  

1<?PHP2     3     //Custom Functions4     functionsows () {5         6         return"You are sows";7     }8     9     //assigning the name of a custom function to a variableTen     $name= "Sows"; One      A     //Add () to the variable to allow the system to use the variable as a function -     Echo $name(); -? >
examples of using php--mutable functions

    

"The Wind horse a clan _php"

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.