[Interview Question] Basic knowledge of PHP

不言
Release: 2023-03-24 21:04:01
Original
1654 people have browsed it

This article introduces the basic knowledge of [Interview Question] PHP, which has a certain reference value. Now I share it with you. Friends in need can refer to it

1. The difference between single and double quotation marks

  • Double quotes parse variables, single quotes do not parse variables,

  • Introduce single quotes in double quotes, if there are variables in single quotes, the variables Parsing

  • Single quotes are faster than double quotes

  • Double quotes parse transfer characters, single quotes do not parse escape characters

2. The difference between Get and post:

  • Get obtains data from the server, and post transmits data to the server

  • The value passed by Get is visible in the url, but the value passed by post is not visible in the url

  • The value passed by Get is generally within 2KB, and the size of the value passed by post can be set in php.ini

  • get security is not low, post security is higher, but the execution efficiency is higher than Post

Suggestion
- The Get method is less secure than the Post method and contains confidential information. It is recommended to use the Post data submission method;
- It is recommended to use the Get method for data query; it is recommended to use the Post method for adding, modifying or deleting data;

3. The difference between include and require

  • require It is an unconditional inclusion. If require is added to a process, require will be executed first regardless of whether the condition is true.

  • include has no return value, while require has a return value

  • include means include. If the file cannot be found, a warning error will be reported. The program can continue to execute.

  • require means necessary. If the file cannot be found, a fatal error will be reported ( Fatal error), the program will stop

  • include_once, require_once The system will make a judgment, and if it is included, it will not include it for the second time

For example, if the system configuration is missing and cannot run, naturally use require. If a certain program is missing, it is just missing the statistical website visits, so it is not essential. You can use include
Adding once or not is the difference in efficiency. Although the system will help you consider including it only once, the system's judgment will reduce efficiency. Therefore, it is better to adjust the directory structure at the beginning of development and try not to use _once

4. The difference between SESSION and COOKIE


1. Cookies are stored in the client browser, session data It is placed on the server
2. Cookies are not very safe. Others can analyze the cookies stored locally for cookie spoofing. Therefore, considering the security and important information, session should be used.
3. The session will be stored on the server for a certain period of time. When access increases, server performance will be occupied. Considering the server pressure issue, it is appropriate to put some information in cookies.
The data size saved by a single cookie cannot exceed 4K, and many browsers will limit one site.

5. There are several data types in php

Four scalar types:

boolean (布尔型)
integer (整形)
float (浮点型,也称作 double)
string (字符串)
Copy after login

Two composite types:

array(数组)
object (对象)
Copy after login

Two special types:

resource (资源)
NULL (NULL)
Copy after login

6, PHP global variables - super global variables

- $GLOBALS
- $_SERVER
- $_REQUEST
- $_POST
- $_GET
- $_FILES
- $_ENV
- $_COOKIE
- $_SESSION
Copy after login

7, PHP time function

time() // 获取当前是时间戳
strtotime() // 将时间格式转换为 unix 时间
date() // 格式化时间戳
date_default_timezone_set() // 设置时区

data('Y-M-D H:i:s',strtotime('-1 day'));
Copy after login

8, PHP common functions for processing arrays

9, PHP processing strings Common functions of

10. Common functions of PHP operating files

Come on.
Related recommendations:

Common interview points for PHP network protocols

3-year PHP programmer interview summary

The above is the detailed content of [Interview Question] Basic knowledge of PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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