function declarations in PHP base-php

Source: Internet
Author: User

/* The range of PHP variables
* Local variables: variables declared in a function are local variables and can only be used inside their own functions.
* Global variables: Declared outside the function, after the variable declaration, until the end of the entire script can be used, including in the function and {} can be used
*
* PHP variables cannot be declared or used,
* Use global variables in PHP to include this global variable in the function through the global keyword to be used, after the global Declaration is the use of globally variable
*
* The parameter is a local variable, which can be assigned when the local variable is called.
*
* Static variables for PHP
*
* Static variables can only be declared in a function (class) and cannot be declared globally
* Use static before the variable;
*
* Function: A variable can be used in multiple invocations of the same function.
* 1. Static variables are saved in a static code snippet
* 2. A function is shared between multiple invocations, but is declared to memory only the first time the function is called, and later invoked, no longer declared, but directly used
*
*variable function:If a variable is followed by parentheses $var=hello $var (), it will look for a function hello () with the same name as the variable value.
*
*
* 1. function------------Decide whether to use this function
* 2. The parameters of the function------------determine how the function is called---there are several arguments, what type of value to pass, ....
* 3. The return value of the function----------How to handle the function after the call
*
* PHP gives more than 2000 functions ... are system functions and can be used directly by name.
*
* Be sure to use the system function first, if the system function does not have the function you want, then go to define the function yourself
*
1. General functions
BOOL Copy (string source, String dest)
2. With mixed, mixed means that any type of data can be transmitted
BOOL Chown (string filename, mixed user)
3. A function with & parameters, indicating the reference assignment, this parameter can not pass the value, can only pass a variable, and then the function will change the value of the variable, we use this variable, the value is also changed
BOOL Arsort (array &array [, int sort_flags])

4. The default function with [] function, indicating that this parameter is optional, if you pass the value of the value you pass, if there is no value to use the default value
When declaring a function directly, the initial value is given to the parameter.
Optional values and mandatory values must be set from the back forward
BOOL Arsort (array &array [, int sort_flags])

5. With ... The parameter function, ... Indicates that any number of arguments can be passed
int Array_unshift (array &array, mixed var [, mixed ...])

6. Callback function with callback, that is, call this function when we need to pass a function to come in (function name, functional name string)
Array array_filter (array input [, callback callback])

function declarations in PHP base-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.