Table of Contents
1. The difference between double quotes and single quotes
Get adds the parameter data queue to the URL pointed to by the action attribute of the submitted form. The value corresponds one-to-one with each field in the form, which can be seen from the URL; post uses the HTTPPOST mechanism to prevent each field and its content in the form from being transmitted together to the URL address pointed to by the action attribute in the HTML head, and the user cannot see it. To this process
The GET request will send a request for data to the database to obtain information. This request Just like the select operation of the database, it is only used to query data. It will not modify or add data, and will not affect the content of the resource, that is, the request will not have side effects. No matter how many times you perform the operation, the result is the same.
##Hypertext Preprocessor----Hypertext Preprocessor
14. What is the difference between the include and require statements? To avoid including the same file multiple times, you can use (?) statements to replace them
15. Talk about the understanding of mvc
16. Explain the value and transfer in PHP The difference between references and explain when to pass by value and when to pass by reference?
Home Backend Development PHP Tutorial Summary of the latest PHP classic interview questions in 2017

Summary of the latest PHP classic interview questions in 2017

Apr 21, 2018 am 10:30 AM
php

The content introduced in this article is a summary of the latest PHP classic interview questions in 2017. It has a certain reference value. Now I share it with you. Friends in need can refer to it.

This article will continue Update, I hope you can express your own opinions and classic topics in the comment area. The author will classify and hierarchize this article at appropriate nodes in the future. I hope you can correct the deficiencies in the article!

1. The difference between double quotes and single quotes

  • Double quotes explain variables, single quotes do not Interpretation of variables

  • Insert single quotation marks inside the double quotation marks. If there is a variable within the single quotation marks, the variable explanation

  • follows the variable name of the double quotation marks. There must be a special character that is not a number, letter, or underscore, or it must be enclosed in a variable. Otherwise, the part after the variable name will be treated as a whole, causing a syntax error

  • ##Double quotation marks Interpret escape characters. Single quotes do not interpret escape characters. However, interpreting '\ and \\

  • can make single quote characters use single quotes as much as possible. Single quotes are more efficient than double quotes. High (because double quotes must be traversed first to determine whether there are variables inside, and then operated, while single quotes do not need to be judged)

2. Commonly used super global variables (8 )

    ##$_GET ----->get transmission method
  • $_POST ----->post transmission method
  • $_REQUEST ----->Can receive values ​​in both get and post methods

    $GLOBALS ----->All variables are placed inside
  • $_FILE ----->Use
  • # to upload files

    ##$_SERVER ----->System environment variables
##$_SESSION ----->Session controlled
  • #$_COOKIE will be used when ----->It will be used when session control

  • 3, POST in HTTP, The difference between GET, PUT, and DELETE methods

HTTP defines different methods for interacting with the server. The most basic ones are POST, GET, PUT, and DELETE. The full name of the indispensable URL is resource. We can understand the descriptor like this: URL describes a resource on the network, and post, get, put, and delegate are the operations of adding, deleting, modifying, and checking this resource!

3.1 The difference between get and post submission methods in the form

Get adds the parameter data queue to the URL pointed to by the action attribute of the submitted form. The value corresponds one-to-one with each field in the form, which can be seen from the URL; post uses the HTTPPOST mechanism to prevent each field and its content in the form from being transmitted together to the URL address pointed to by the action attribute in the HTML head, and the user cannot see it. To this process
  • For the get method, the server uses Request.QueryString to obtain the value of the variable. For the post method, the server uses Request.Form to obtain the submitted data

  • The amount of data transmitted by get is small, and the amount of data transmitted by post is larger. It is generally unrestricted by default. However, in theory, the maximum amount is 80kb in IIS4 and 1000k in IIS5. Get is very secure. Low, post security is high

  • 3.2

The GET request will send a request for data to the database to obtain information. This request Just like the select operation of the database, it is only used to query data. It will not modify or add data, and will not affect the content of the resource, that is, the request will not have side effects. No matter how many times you perform the operation, the result is the same.
  • Different from GET, the PUT request sends data to the server to change the information. This request is just like the update operation of the database, used to modify the content of the data, but The type of data will not be increased, which means that no matter how many PUT operations are performed, the results will not be different.

  • POST request is similar to PUT request, both send data to the server, but this request will change the type of data and other resources, just like the insert operation of the database, it will create new Content. Almost all current submission operations are requested using POST.

  • DELETE request, as the name suggests, is used to delete a certain resource. This request is like the delete operation of the database.

  • 4. Introduction to PHP

##Hypertext Preprocessor----Hypertext Preprocessor

Personal Home Page Original name

Target purpose:

Allows web developers to quickly write dynamically generated web pages. Compared with other pages, PHP embeds programs into HTML documents for execution, and is more efficient than Fully generated CGI for HTML editing is much higher

HTML: Hypertext Markup Language

Founder: Rasmus Lerdorf , born in 1968, University of Waterloo, Canada

Ledolf ​​first wrote the maintenance program in prel language to maintain his personal web page, and then rewritten it in c, which eventually led to php/fi

Timeline:

  • 1995.06.08 Public release of PHP/FI

  • 1995 php2.0, adding support for MySQL

  • 1997 php3.0

  • 2000 php4.0

  • 2008 php5.0

  • Since php6.0 does not fully solve Unicode encoding, there is basically no application on the production line. It is basically just a concept product. Many functions have been implemented on php5.3.3 and php5.3.4

Common IDE(Intergrated Development Environment): Integrated Development Environment

  • Coda (mac)

  • ##PHPStrom

  • Adobe Dreamweaver

  • NetBeans

Common text editor with code highlighting :

  • NodePad

  • SublimeText

PHP Advantage

PHP features:

  • php uniquely mixes C, Java, Prel and PHP’s own syntax

  • can be compared CGI or Prel can execute dynamic web pages faster. Compared with other programming languages, PHP embeds programs into HTML documents for execution. The execution efficiency is much higher than CGI that completely generates HTML editing. All CGI can be implemented.

  • Supports almost all popular databases and operating systems

  • PHP can use C and C to extend the program

Advantages of PHP:

  • Open source

  • Free sex

  • Quickness

  • Strong cross-platform

  • High efficiency

  • Graphics processing

  • Object-oriented

  • Professional focus

PHP technology application:

  • Static page generation

  • Database cache

  • Process cache

  • p css w3c standard

  • Big load

  • Distributed

  • flex

  • Support MVC

  • Smarty module engine

PHP certification level

  • Junior IFE: Index Front Engineer Front-end Engineer

  • Intermediate IPE: Index PHP Engineer PHP Engineer

  • Advanced IAE: Index Architecture Engineer Architecture Engineer

6. The difference between echo, print_r, print, and var_dump

* echo、print是php语句,var_dump和print_r是函数
* echo 输出一个或多个字符串,中间以逗号隔开,没有返回值是语言结构而不是真正的函数,因此不能作为表达式的一部分使用
* print也是php的一个关键字,有返回值 只能打印出简单类型变量的值(如int,string),如果字符串显示成功则返回true,否则返回false* print_r 可以打印出复杂类型变量的值(如数组、对象)以列表的形式显示,并以array、object开头,但print_r输出布尔值和NULL的结果没有意义,因为都是打印"\n",因此var_dump()函数更适合调试
* var_dump() 判断一个变量的类型和长度,并输出变量的数值
Copy after login

7. HTTP status code

Click here to view HTTP Detailed explanation of status codes

Common HTTP status codes:

  • 200 - Request successful

  • 301 - The resource (web page, etc.) is permanently escaped to another URL

  • 404 - The requested resource (web page, etc.) does not exist

  • 505 - Internal Server Error

HTTP status code classification:

  • 1** - Information, request received by the server, The requester is required to continue performing the operation

  • 2** - Success, the operation was successfully received and processed

  • 3** - Redirect, required Further action to complete the request

  • 4** - Client error, the request contains a syntax error or the request cannot be completed

  • 5** Server Error. An error occurred while the server was processing the request.

8. What are magic quotes?

Magic quotes are a symbol that will automatically convert the data entering the PHP script. In the process of definition, it is best not to escape when encoding but to escape as needed during runtime

9. How to obtain the client's IP (requires an int) and the code of the server's IP

Client:

$_SERVER["REMOTE_ADDR"]; or getenv('REMOTE_ADDR')ip2long for conversion Server: gethostbyname('www.baidu.com')

10. Use those tools for version control
cvs, svn, vss, git

11. How to optimize the database

MySQL database Eight ways to optimize (classic must-see) Click to get
  • Select the most applicable field attributes, reduce the width of the defined fields as much as possible, and try to set the fields to NOTNULL, such as 'province', 'gender' 'It is best to use ENUM

  • Use joins (JOIN) instead of subqueries

  • Use unions (UNION) instead of manually created temporary tables

  • Transaction processing

  • Lock table, optimize transaction processing

  • Apply foreign keys, optimize locking Table

  • Create index

  • Optimize query statement

12. Have you ever used a template engine? What is the name of the template engine used?

Smarty:Smarty is a very old PHP template engine. It was my initial choice for using templates in this language. Although it is updated less frequently and lacks some features of the new generation of template engines, it is still worth a look.

13. For high-traffic websites, what methods should be used to solve the traffic problem

  • Confirm whether the server hardware can support the current traffic

  • Separate reading and writing of database, optimize data tables

  • Program function rules, prohibit external hot links

  • Control large files download

  • Use different hosts to divert main traffic

14. What is the difference between the include and require statements? To avoid including the same file multiple times, you can use (?) statements to replace them

  • require is an unconditional inclusion, that is, if require is added to a process, it will be executed first regardless of whether the condition is true or not. require, when the file does not exist or cannot be opened, an error will be prompted and the program execution will be terminated

  • include has a return value, but require does not (maybe because require is faster than include Fast), if the included file does not exist, an error will be prompted, but the program will continue to execute.

Note: When the included file does not exist or the syntax is wrong, require is Fatal, and include is not

  • require_once means it is included only once, avoiding repeated inclusion

15. Talk about the understanding of mvc

The application is completed by the model, view, and controller. The model sends the functions to be implemented to the controller, and the controller receives the organizational functions and passes them to the view

16. Explain the value and transfer in PHP The difference between references and explain when to pass by value and when to pass by reference?

Variables are always assigned by value by default, that is to say, when the value of an expression is assigned to a variable, the value of the entire expression is assigned to the target variable, which means: When When one variable is assigned to another variable, changing the value of one variable will not affect the other variable

php also provides another way to assign values ​​to variables: reference assignment. This means that the new variable simply __references__ (in other words, becomes an alias or pointer to) the original variable. Changes to new variables will affect the original variables and vice versa. Use reference assignment, simply add an & symbol before the variable to be assigned (source variable)

The object defaults to pass-by-reference. For larger data, it is better to pass by reference, which can save memory overhead.

Related recommendations:

Summary of php interview questions

PHP classic interview question setPHP classic interview question set

The most complete and detailed PHP interview questions (with answers)

The above is the detailed content of Summary of the latest PHP classic interview questions in 2017. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles