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

Explanation of advanced applications of PHP

烟雨青岚
Release: 2023-04-08 22:02:01
forward
2255 people have browsed it

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);
)
Copy after login

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].".<br>";
echo $cars[1][0].": 库存:".$cars[1][1].", 已售:".$cars[1][2].".<br>";
echo $cars[2][0].": 库存:".$cars[2][1].", 已售:".$cars[2][2].".<br>";
echo $cars[3][0].": 库存:".$cars[3][1].", 已售:".$cars[3][2].".<br>";
Copy after login

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 The strtotime() function that creates time, strtotime() function can 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!

Related labels:
php
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template