PHP Syntax Basics 5

Source: Internet
Author: User

keyword global:

used to make a function call an external variable, but it is not to make the variable super-global. Instead of 1, a local variable is defined inside the function and the name of the local variable is exactly the same as the name of a global variable outside! 2, copy the address of the value of the outside global variable, pass it to the local variable defined inside the function (use $GLOBALS as much as possible in programming , because it is really defining a super global variable)


Static local variables:

The keyword that defines it is:static

Feature: Each time the function is called, the static local variables will be saved without disappearing (the next time you call it can then be used), but at the end of the function call, it also ends.



Recursive functions:

function itself to call itself;

recursive two elements :

    1. Recursive exit: When to stop yourself calling yourself when you start calling yourself

    2. Recursion point: When do you start calling yourself

(generally write recursive exit and write recursion point)



The iterative idea is to solve the problem from the point of travel, which is embodied in the code, which is actually a repetitive execution of a step, that is, the loop structure.



Time function:

Date: uses the time format placeholder to format the specified timestamp in the form of a corresponding format , such asdate(y) , output, y forthe year.

Strtotime: Converts a time string in an English format to a timestamp!

such as strtotime ("2016-9-10"); is converted into a timestamp


Time function:

Date: uses the time format placeholder to format the specified timestamp in the form of a corresponding format , such as:date(y), Output ,y Represents the year.

Strtotime: Converts a time string in an English format to a timestamp!

such as strtotime ("2016-9-10"); is converted into a timestamp



To create an array:

Explicitly created:

$arr =array (

' key name ' = = ' value ',

Key Name 1 ' = = ' value 1 ',

Key Name 2 ' = = ' value 2 ',

);

Implicitly created:

$arr [' Key name ']= ' value ',

$arr [' Key name 1 ']= ' value 1 ',

$arr [' Key name 2 ']= ' value 2 ',

$arr [' Key name 3 ']= ' value 3 ',

Var_dump ($arr);



Array classification:

1. indexed array: The key of an array element, not the meaning of its value, only the position of the element within the entire array

2. Associative arrays: There is a one by one corresponding relationship between the key and the value of the exponent group element, that is, the key means its value!


PHP Syntax Basics 5

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.