Eon PHP video Tutorial first quarter resource sharing

Source: Internet
Author: User
Tags php tutorial
PHP is one of the most popular languages today. Li Tinghui as a master of the PHP training community, the course is well-organized, comprehensive knowledge. His PHP tutorial video is a classic, widely circulated on the Internet. This course is his first season video, a basic knowledge of PHP.

Course Play Address: http://www.php.cn/course/392.html

The teacher's lecture style:

The teacher lively image, witty witty, witty, touching. A vivid image of the metaphor, like the finishing touch, to the students to open the door of wisdom, a proper sense of humor, attracting students to smile, such as drinking a cup of glycol wine, to the aftertaste and nostalgia, the philosopher's motto, culture of the proverbs from time and again interspersed in the middle, give people to think and alert.

The more difficult part of this video is the PHP custom function:

In general, redundant code is bad. Again and again, rewriting the code again not only a waste of time, but also from a structural point of view. Like all good programming languages, PHP uses a number of methods to alleviate the problem of redundant code, the most common and easiest to implement is to use functions.

A Standard functions

There are more than 1000 standard functions in the standard PHP release package, which are built into the system and can be used directly without the user's own creation.

<?echo MD5 (' 123456 ');   The MD5 function encrypts a string?>

Two Custom functions

PHP built-in functions allow you to interact with files, use databases, create graphics, and connect to other servers. However, in practical work, there are many times when what is needed is not foreseen by the creator of the language.

Declaring a function allows us to use our own code like a built-in function. Simply call this function and give it the necessary arguments. This means that the same function can be called and reused multiple times throughout the script.

Create a function

<?function functionname () {echo ' This is a no parameter no return custom function ';}? >

Calling functions

<?functionname ();? >

function naming

1. The function name cannot be the same as the existing function name.

2. Function names can only contain letters, numbers, and underscores.

3. Function names cannot begin with a number.

Function call with no return for parameter

<?function Functionarea ($radius) {Area=radius * $radius * PI (); echo $area;} functionarea (10); >

The include parameter has a function call returned: Use the return () statement to return any determined value to the function caller and return the control of the program to the scope of the caller.

<?function Functionarea ($radius) {return Radius∗radius * PI ();} Echo Functionarea (10); >

function calls with default parameters: You can specify a default value for the input parameter, and the default value is automatically assigned to the parameter if no other value is provided.

<?function Functionarea ($radius =10) {return Radius∗radius * PI ();} echo Functionarea ();? >

function calls that return multiple values: can be constructed by returning an array and then using the list () function.

<?function Functioninfo (Name,age, $job) {Userinfo=array (name,age,job);  You can compare commonly used return $userInfo in an additional way;} List (name,age, $job) = Functioninfo (' Wu Qi ', 19, ' student '), echo this year name.′ ′.age. ' year old, is still a '. $job; >

A function call that contains a reference to a parameter: reference passing can also respond to changes in parameters within a function beyond the scope of the function.

< $prices = $tax = 0.5;function functionprices (&prices,tax) {prices=prices + (prices∗tax); Tax=tax * 2;} functio Nprices (prices,tax); echo $prices; Echo ' <br/> '; echo $tax;? >

Note that function calls are not case-sensitive, so calling functionname (), functionname (), or functioinname () is valid and will return the same result. For convenience, this is done in lowercase.

It is important that the

Note that the function name and variable name are different. Variable names are case-sensitive, so $name and $name are two different variables, but name () and name () are the same function.

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.