Basic php knowledge: basic function knowledge

Source: Internet
Author: User

Function, all languages are available, so here only focus on:

1> definition: php does not need to define the return value type.
2> the function name is case-sensitive. However, when calling a function, it is usually defined in the same format.
3> all functions and classes in PHP are fully local, and external calls can be defined internally, and vice versa.
4> PHP does not support function overloading, and it is impossible to cancel or redefine declared functions.
5> recursive functions can be called in PHP. However, avoid calling recursive functions/methods that exceed layer 100-layer 200, because the stack may be broken to terminate the current script.
6> parameters with default values must be at the end of the parameter table.
7> variable functions. You can call a function by renaming the function.
For example:
Function helloWorld ($ name = 'php ')
{
Echo "Hello World". $ name;
}
$ Func = helloWorld;
$ Func (); // call the helloWorld Function
$ Func ('saga '); // call helloWorld with Parameters
8> variable length parameter list:
It mainly relies on three functions: func_num_args (), func_get_arg (), and func_get_args ()
Description:
Int func_num_args () returns the number of passed parameters. (PHP4, PHP5)
Mixed func_get_arg (int arg_num) returns the arg_num parameter (counted from 0)
Array func_get_args () returns the parameter expression group.

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.