Summary of the latest PHP classic interview questions in 2017 (previous article), and last article in 2017

Source: Internet
Author: User
Tags index php php template

Summary of the latest PHP classic interview questions in 2017 (previous article), and last article in 2017

1. Difference Between Double quotation marks and single quotation marks

  • Double quotation marks are used to interpret variables.
  • Insert single quotes in double quotes. If there is a variable in single quotes, the variable is interpreted.
  • A variable name in double quotation marks must be followed by a special character that is not a number, letter, or underscore, or be enclosed in a variable {}. Otherwise, the part after the variable name is considered as a whole, cause syntax error
  • Double quotation marks are used to interpret escape characters \\
  • The single quotation mark character can use single quotation marks as much as possible. The efficiency of single quotation marks is higher than that of double quotation marks (because double quotation marks must be traversed first to determine whether there are any variables in them and then operated on them, but single quotation marks do not need to be judged)

2. Common super global variables (8)

  • $ _ GET -----> get Transmission Method
  • $ POST -----> post Transmission Method
  • $ REQUEST -----> can receive get and post values.
  • ***
  • $ GLOBALS -----> put all the variables in it
  • $ FILE -----> used to upload files
  • $ SERVER -----> system environment variables
  • ***
  • $ SESSION -----> used in SESSION control
  • $ COOKIE -----> used for session control

3. Differences between POST, GET, PUT, and DELETE methods in HTTP

HTTP defines different methods for interaction with the server. The most basic method is POST, GET, PUT, and DELETE. The full name of an indispensable URL is the resource descriptor. We can understand it as follows: a url describes a network resource, and post, get, put, and delegate are operations to add, delete, modify, and query this resource!

3.1 differences between get and post submission methods in Forms

  • Get is to add the parameter data queue to the url referred to by the action attribute of the submission form. The values correspond to each field in the form one by one and can be seen from the url. post is implemented through the HTTPPOST mechanism, this process prevents the fields and content in the form from being transmitted to the url address specified by the action attribute in the HTML head.
  • 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 size of data transmitted by get is small. The size of data transmitted by post is large, which is not restricted by default. However, in theory, the maximum size of IIS4 is 80 KB, and that of IIS5 is 1000 kb,
  • Low get security and high post security

3.2

  • A GET request sends a data request to the database to obtain information. The request is like a select operation in the database. It is only used to query data and does not modify or add data, does not affect the content of the resource, that is, the request does not produce any side effects. The results are the same no matter how many operations are performed.
  • Unlike GET, a PUT request sends data to the server to change the information. The request is used to modify the data content just like the update operation of the database, however, no data types are added. That is to say, no matter how many PUT operations are performed, the results are not different.
  • Similar to PUT requests, a POST request sends data to the server. However, this request changes the data type and other resources, just like the insert operation of the database, and creates new content. Almost all the currently submitted operations use POST requests.
  • A delete request, as its name implies, is used to delete a resource. It is like a DELETE operation in a database.

4. Introduction to PHP

Hypertext Preprocessor ---- Hypertext Preprocessor

Original Personal Home Page name

Purpose: allow web developers to quickly compile dynamically generated web pages. Compared with other pages, PHP embeds programs into HTML documents for execution, the efficiency is much higher than that of CGI that completely generates HTML editing.

HTML: Hypertext Markup Language

Founder: Rasmus Lerdorf, 1968 student, University of Waterloo, Canada

Ldorf first wrote maintenance programs in the prel language to maintain personal web pages, and then rewritten them in c to generate php/fi.

Timeline:

  • 1995.06.08 release PHP/FI publicly
  • 1995 php2.0, added support for MySQL
  • 1997 php3.0
  • 2000 php4.0
  • 2008 php5.0
  • PHP does not fully address Unicode encoding, so there is basically no application on the production line. It is basically a concept product and 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 advantages

PHP features:

  • Php's unique mix of C, Java, Prel, and PHP's own syntax
  • Dynamic Web pages can be executed more quickly than CGI or Prel. Compared with other languages, PHP is embedded into HTML documents for execution, the execution efficiency is much higher than that of CGI that completely generates HTML edits. All CGI can be implemented.
  • Supports almost all popular databases and Operating Systems
  • PHP can use C and C ++ for program Extension

PHP advantages:

  • Open source code
  • Free
  • Quick
  • Strong cross-platform
  • High Efficiency
  • Graphic Processing
  • Object-oriented
  • Professional and dedicated

PHP Technology Application:

  • Static Page generation
  • Database cache
  • Process Cache
  • Div + css w3c Standard
  • High Load
  • Distributed
  • Flex
  • Support for MVC
  • Smarty module Engine

PHP certification level

IFE: Front-end Engineer of Index Front Engineer
Intermediate IPE: Index PHP Engineer
Senior IAE: Index Architecture Engineer

6. Differences between echo, print_r, print, and var_dump

* Echo and print are php statements, and var_dump and print_r are functions * echo outputs one or more strings separated by commas. No returned values are language structures rather than real functions, therefore, * print cannot be used as part of the expression and is also a keyword in php. If a return value is returned, only the values of simple type variables (such as int and string) can be printed. If the string is displayed successfully, true is returned, otherwise, false * print_r can be returned to print the values of complex variables (such as arrays and objects) in the form of a list and start with array and object, however, print_r outputs boolean values and NULL results without significance. Because both print "\ n", the var_dump () function is more suitable for debugging * var_dump () to determine the type and length of a variable, and output the variable value.

7. HTTP status code

Click here to view the HTTP status code details

Common HTTP status codes:

200-request successful
301-resources (web pages, etc.) are permanently escaped to other URLs
404-the requested resource (webpage, etc.) does not exist
505-an internal server error occurs.
HTTP status code category:

1 **-Information: The request received by the server, which requires the requester to continue the operation
2 **-operation received and processed successfully
3 **-redirection. Further operations are required to complete the request.
4 **-client error. The request contains a syntax error or the request cannot be completed
*** Server error: the server is processing the request
An error occurred.

8. What are magic quotes?

Magic quotes are a process that will automatically escape the data that enters the PHP script. It is best to escape the data without escaping during encoding and escape the data as needed during running.

9. How to obtain the Client ip (requires an int) and Server ip code

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. Database Optimization Methods

Eight Methods of MySQL database optimization (required for classic) Click to get

Select the most suitable field attribute, minimize the width of the defined field, and set the field as NOTNULL as much as possible. For example, it is best to apply ENUM to 'province 'and 'gender '.
Use JOIN instead of subquery
UNION is used to replace the temporary table created manually.
Transaction Processing
Locking tables and optimizing Transaction Processing
Apply Foreign keys to optimize table locking
Create an index
Optimize Query statements

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

Smarty: Smarty is a very old PHP template engine. It was my first choice to use this language template. Although it is not updated frequently and lacks some features of the new generation template engine, it is still worth looking.

13. How does one solve the traffic issue for a large-traffic website?

Check whether the server hardware supports the current traffic.
Database read/write splitting to optimize data tables
Program function rules to prohibit external leeching
Control the download of large files
Use different hosts to distribute major traffic

14. What is the difference between the include statement and require statement? To avoid multiple times containing the same file, you can use (?) Statement instead of them

Require is unconditionally contained, that is, if require is added to a process, require will be executed no matter whether the condition is true or not. When the file does not exist or cannot be opened, an error will be prompted, the program execution will be terminated.

Include has a return value, while require does not (probably because so require is faster than include). If the included file does not exist, an error will be prompted, but the program will continue to execute.

Note: When the contained file does not exist or the syntax is incorrect, require is fatal, and include is not

Require_once indicates that only one request is included.

15. About mvc

An application completed by a model, view, or controller. The model sends the functions to the Controller, and the Controller receives the organizational functions and passes them to the view.

16. It indicates the difference between passing a value in php and passing a reference, and when will the value be passed for reference?

By default, a value is always assigned, that is, 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 a variable is assigned to another variable, changing the value of one variable does not affect another variable.

Php also provides another way to assign values to variables: assign values to references. This means that the new variable is simple _ referenced _ (in other words, it becomes its alias or points to) the original variable. The new variable will affect the original variable, and vice versa. Assign values by reference. Simply add an & symbol to the variable to be assigned (source variable)

Objects are referenced by default.

For large data, it is better to transmit the reference, which can save the memory overhead.

The above is a summary of the latest PHP classic interview questions in 2017 (Part 1). I hope it will help you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.