Home>Article>Backend Development> Explanation of advanced applications of PHP

Explanation of advanced applications of PHP

烟雨青岚
烟雨青岚 forward
2020-06-15 17:42:58 2148browse

Explanation of advanced applications of PHP

Explanation of advanced PHP applications

##1. PHP multi-dimensional array

PHP can understand two-level, three-level or even four- to five-level multi-dimensional arrays. The dimensions of the array indicate the index number of elements that need to be selected. For a two-dimensional array, two indexes are needed to select elements, and for a three-dimensional array, three indexes are needed to select elements. For example, the following array:

$car = array( array("Volvo",33,20); array("BMW",17,15); array("Land Rover",15,11); )

This is a two-dimensional array, including rows and columns, so you need to use two indexes to select elements:

echo $cars[0][0].": 库存:".$cars[0][1].", 已售:".$cars[0][2].".
"; echo $cars[1][0].": 库存:".$cars[1][1].", 已售:".$cars[1][2].".
"; echo $cars[2][0].": 库存:".$cars[2][1].", 已售:".$cars[2][2].".
"; echo $cars[3][0].": 库存:".$cars[3][1].", 已售:".$cars[3][2].".
";

In order to select the required elements.

2. PHP date

The function to obtain time in PHP is Date(). The parameters in the function can include year, month, day, hour, minute and second. , characters can be inserted between parameters for date output. One thing to note is the time zone issue. Generally, if no modifications are made to the php.ini file, the time zone will generally lock the enemy with zero time difference. If you want to change it to Chinese time, you need to change the value of date.timezone in the php.ini file. It is PRC, so that you can get the Chinese time. There is also the function mktime() that creates time in PHP. There are six elements in the function brackets: hour, minute, second, month, day, year. This is a function to create time with a series of parameters, and there are also strings Thestrtotime() functionthat creates time,strtotime() functioncan convert a human-readable string into Unix time. PHP is very smart at string conversion time, so it can use various values to convert.

3. PHP include

include statement will get all the text/code/tags present in the specified file and copy them to the file using the include statement. If you need to reference the same PHP or HTML on multiple pages of the website, the value of the included file will be reflected. There are two ways to reference PHP files: include and require. There is a slight difference between these two ways. include will only generate a warning when handling errors, while require will generate a fatal error and stop when handling errors. script. The import format is include 'filename.php', and require is the same.

Thank you everyone for reading, I hope you will benefit a lot.

This article is reproduced from: https://blog.csdn.net/ydydyd00/article/details/70243979

Recommended tutorial: "

php tutorial"

The above is the detailed content of Explanation of advanced applications of PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete