2017 Latest PHP Classic interview topics Summary

Source: Internet
Author: User
Tags index php php template
This article introduces the content is about 2017 of the latest PHP classic Interview topic Summary, has a certain reference value, now share to everyone, the need for friends can refer to

This article will continue to update, I hope to be able to publish their views in the comment area and think of more classic topics, follow-up author will be in the appropriate node for this article classification and hierarchical Division. The shortcomings of the article look at more guidance, correct!

1. The difference between double quotation marks and single quotation marks

    • Double quote explanatory variable, single quote not explanatory variable

    • Double quotation marks in single quotes, where there are variables in single quotes, the variable interpretation

    • The variable name of double quotes must be followed by a special character that is not a number, a letter, an underscore, or enclosed in a variable name, otherwise it will be a whole, resulting in a syntax error

    • Double quotes interpret escape characters, single quotes do not interpret escape characters, but explain ' \ and \ \

    • The single quote character can be used as much as possible single quotation marks, the efficiency of single quotation marks is higher than double quotation marks (because the double quotation marks to go through, to determine if there are no variables, and then the operation, and single quotation marks do not need to judge)

2, commonly used super-global variables (8)

    • $_get----->get Transfer Mode

    • $_post----->post Transfer Mode

    • $_request-----> can receive values for get and post two ways

    • $GLOBALS-----> All the variables are in there.

    • $_file-----> Upload files using

    • $_server-----> System Environment variables

    • $_session-----> Session control will be used.

    • $_cookie-----> Session control will be used.

3. The difference between post, GET, PUT, delete in HTTP

HTTP defines a different approach to interacting with the server, the most basic is the post, get, put, DELETE, and its more than the full name of the URL is a resource descriptor, we can understand that: the URL describes a resource on the network, and post, get, put, Delegate is to this resource to increase, delete, change, check the operation!

3.1 Differences in how get and post are submitted in the form

    • Get is the URL where the parameter data queue is added to the Action property of the submission form, and the value corresponds to the field one by one in the form, which is visible from the URL; Post is through the httppost mechanism, The user cannot see this procedure by preventing the fields in the form from being routed to the URL address in the HTML's head, which is referred to by the Action property.

    • For Get mode, the server side uses Request.QueryString to get the value of the variable, and for post, the server uses Request.Form to get the submitted data.

    • The amount of data sent by the get is small, the amount of data sent by the post is large and is generally not restricted by default, but in theory, the maximum IIS4 in 80KB,IIS5 is 1000k,get security is very low, post security is high

3.2

    • A GET request sends a request for data to the database to obtain information, which, like a database's select operation, simply queries the data, does not modify, add data, and does not affect the contents of the resource, that is, the request does not have side effects. The results are the same no matter how many times you do it.

    • Unlike get, a put request is a change of information by sending data to the server, which, like the database update operation, modifies the contents of the data, but does not increase the type of data, that is, the result is not different regardless of the number of put operations.

    • A POST request, like a put request, sends data to the server, but the request alters resources such as the type of data, and creates new content just like the insert operation for a database. Almost all of the current commit operations are requested by post.

    • The delete request, as its name implies, is used to delete a resource, which is like a database delete operation.

4. Introduction to PHP


Hypertext Preprocessor----Hypertext preprocessor

Personal Home Page Original name

Purpose: allows Web developers to quickly write dynamically generated Web pages, compared to other pages, PHP is to embed the program into the HTML document to execute, more efficient than the fully generated HTML editing CGI much higher

HTML: Hypertext Markup Language

founder: Ramsler Loedorf Rasmus lerdorf,1968, University of Waterloo, Canada

Lodorf was initially designed to maintain personal web pages, wrote maintenance programs in Prel language, and then rewritten with C, eventually deriving Php/fi

Time axis:

    • 1995.06.08 to release Php/fi publicly

    • 1995 php2.0, added support for MySQL

    • 1997 php3.0

    • php4.0

    • php5.0

    • Since php6.0 does not fully resolve Unicode encoding, there is basically no application on the production line, basically just a concept product, many features 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

A common text editor with code highlighting:

    • nodepad++

    • Sublimetext

PHP Advantages

PHP Features:

    • PHP has a unique mix of C,java,prel and PHP's self-created syntax

    • Can be faster than CGI or Prel to execute Dynamic Web pages, and other become a language, PHP is a program embedded in the HTML document to execute, the efficiency is more efficient than the full generation of HTML editing CGI is much higher, all CGI can be implemented

    • Support for almost all popular databases and operating systems

    • PHP can use c,c++ to extend the program

PHP Advantages:

    • Open Source Code

    • Free Sex

    • Quick Sex

    • Cross-platform Strong

    • High efficiency

    • Graphics processing

    • Object oriented

    • Professional focus

PHP Technology Applications:

    • Static page Generation

    • Database Cache

    • Procedure Cache

    • P+CSS Standard

    • Heavy Duty

    • Distributed

    • Flex

    • Support MVC

    • Smarty Module engine

PHP Authentication Level

    • Junior Ife:index Front Engineer front-end engineer

    • Intermediate ipe:index php Engineer PHP Engineer

    • Senior Iae:index Architecture Engineer Architecture Engineer

6. The difference between echo, Print_r, print, Var_dump

* Echo, Print is a PHP statement, var_dump and Print_r are functions * echo output one or more strings, separated by commas, no return value is a language structure instead of a real function, and therefore cannot be used as part of an expression * Print is also a keyword in PHP that has a return value that prints only the value of a simple type variable (such as int,string) and returns True if the string display succeeds, otherwise false* Print_r can print out the value of a complex type variable (such as an array, Object) is displayed as a list, beginning with an array, an object, but Print_r output a boolean and null result is meaningless, because all is printed "\ n", so the Var_dump () function is more suitable for debugging * VAR_DUMP () to determine the type and length of a variable, and output the value of the variable

7. HTTP Status Code

Click here to see an explanation of HTTP status code

Common HTTP Status codes:

    • 200-Successful request

    • 301-Resources (Web pages, etc.) are permanently escaped to other URLs

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

    • 505-Internal Server error

HTTP Status Code classification:

    • 1**-Information, requests received by the server that require the requestor to continue to perform the operation

    • 2**-Successful, the operation is successfully received and processed

    • 3**-redirect, requires further action to complete the request

    • 4**-Client error, request contains syntax error or unable to complete request

    • 5** Server error, the server has an error while processing the request

8. What is Magic Quotes

Magic Quotes are a process that automatically escapes data into a PHP script, preferably not escaped while encoding and escaped as needed at run time

9, how to obtain the client's IP (requires an int) and the server IP code

Client: $_SERVER["REMOTE_ADDR"];或者getenv('REMOTE_ADDR') ip2long进行转换 Server side:gethostbyname('www.baidu.com')

10. Use those tools for version control

CVS, SVN, VSS, git

11, the method of optimizing the database

Eight ways to optimize MySQL database (classic must-see) Click to get

    • Select the most applicable field properties, minimize the width of the field as much as possible, and set the field to Notnull, such as ' Province ', ' gender ', best for enum

    • Use connection (join) instead of subquery

    • Apply Union (Union) instead of manually created temporary table

    • Transaction processing

    • Lock table, optimize transaction processing

    • Apply foreign key, optimize lock table

    • Build an index

    • Refine query statements

12. Have you 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 first choice to use this language template. Although its update is not frequent and lacks some of the features of the next-generation template engine, it is still worth seeing.

13, for the large-flow site, the use of what method to solve the problem of access volume

    • Verify that the server hardware is capable of supporting current traffic

    • Database reading and writing separation, optimizing data table

    • program function rules, prohibit external hotlinking

    • Control the download of large files

    • Divert primary traffic with different hosts

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

    • Require is an unconditional inclusion, that is, if a process joins require, whether or not the condition will be executed first require, when the file does not exist or cannot be opened, will prompt the error, and will terminate the program execution

    • Include has a return value, and require does not (possibly because this require faster than include), if the contained file does not exist, then will prompt an error, but the program will continue to execute

Note: Require is fatal when the include file does not exist or is syntactically incorrect, and include is not

    • Require_once indicates that it is included only once to avoid repeating the inclusion

15, talk about the understanding of MVC

Applications that are completed by models, views, and controllers, emitted by the model to implement the functions to the Controller, the controller receives the organizational functions passed to the view

16. Explain the difference between the value and the reference in PHP, and explain when the value of the transfer is quoted?

Variables are always assigned by default, that is, when a 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 of the variables will not affect the other variable

PHP also provides another way to assign a value to a variable: reference assignment. This means that the new variable has a simple __ reference __(in other words, becomes its alias or points to) the original variable . Changes to the new variable will affect the original variable and vice versa. Use reference assignment to simply add a & symbol to the variable that will be assigned (source variable)

The object by default is a reference to a large data, the reference is better, which can save memory overhead

Related Article

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.