In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces what are the classic interview topics of PHP. It is very detailed and has a certain reference value. Friends who are interested must finish it!
1. The difference between double quotes and single quotation marks
Double quotation marks explain variables, single quotation marks do not explain variables
Insert single quotation marks in double quotes, in which if there is a variable in the single quotation mark, the variable is explained.
The 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 {} variables, otherwise the following part of the variable name will be treated as a whole, causing syntax errors
Double quotation marks explain escape characters, single quotation marks do not interpret escape characters, but explain'\ and\\
Can make single quote characters use single quotation marks as much as possible, single quotation marks are more efficient than double quotation marks (because double quotation marks have to be traversed first to determine whether there are variables in them, and then operate, while single quotation marks do not need to be judged)
2. Commonly used hyperglobal variables (8)
$_ GET-> get transfer mode
$POST-> post transfer mode
$REQUEST-> can receive values in both get and post modes
***
$GLOBALS-> all variables are put in it
$FILE-> use to upload files
$SERVER-> system environment variables
* * *
$SESSION-> session control will be used
$COOKIE-> session control will be used
3. The difference among POST, GET, PUT and DELETE in HTTP.
HTTP defines different ways to interact with the server, the most basic of which are POST, GET, PUT and DELETE. The full name of URL is a resource descriptor. We can understand it this way: url describes a resource on the network, and post, get, put, and delegate are the operations to add, delete, change, and check this resource!
3.1 differences between get and post submission methods in forms
Get adds the parameter data queue to the url referred to by the action attribute of the submitted form, and the value corresponds to each field in the form one by one, as can be seen from the url. Post uses the HTTPPOST mechanism to prevent each field in the form, together with its contents, from being transmitted in the head of the HTML to the url address referred to by the action attribute, and the user cannot see this process.
For get mode, the server uses Request.QueryString to get the value of the variable, and for post mode, 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 large, which is generally unlimited by default, but in theory, the maximum amount of data transmitted by IIS4 is 80kb in IIS4 and 1000k in IIS5.
Get security is very low, post security is high.
3.2
The GET request sends a request for data to the database to obtain information. Just like the select operation of the database, the request is only used to query the data, does not modify or increase the data, and does not affect the content of the resource, that is, the request will not cause side effects. No matter how many operations are performed, the result is the same.
Unlike GET, the PUT request sends data to the server, thus changing the information. Like the update operation of the database, the request is used to modify the content of the data, but does not increase the type of data, etc., that is, no matter how many PUT operations are performed, the result is not different.
POST requests are similar to PUT requests in that they send data to the server, but the request changes resources such as the type of data, just like the insert operation of a database, and creates new content. Almost all current submission operations are requested with POST.
As the name implies, a DELETE request is used to delete a resource, which is like a delete operation in a database.
4. PHP introduction
Hypertext Preprocessor---- hypertext preprocessor
Personal Home Page original name
Purpose: allow web developers to quickly write dynamically generated web pages. Compared with other pages, PHP embeds programs into HTML documents for execution, which is much more efficient than CGI that completely generates HTML edits.
HTML: Hypertext Markup Language
Founder: Ramsler Ledorf Rasmus Lerdorf, born in 1968, University of Waterloo, Canada
Ledorf first wrote the maintenance program in prel language in order to maintain his personal web page, then rewrote it in c, and finally derived php/fi.
Timeline:
On June 08, 1995.06.08, PHP/FI was publicly released.
1995 php2.0, added support for MySQL
1997 php3.0
2000 php4.0
2008 php5.0
Because php6.0 does not completely solve Unicode coding, there is basically no application on the production line, it is basically a conceptual 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 editors with code highlights:
NodePad++
SublimeText
PHP advantage
PHP features:
Php is a unique mix of the syntax created by PHP and Java, which is a unique blend of C & J and Java.
Dynamic web pages can be executed more quickly than CGI or Prel. Compared with other languages, PHP is executed by embedding programs into HTML documents, and the execution efficiency is much higher than that of CGI that completely generates HTML edits. All CGI can be implemented.
Support almost all popular databases and operating systems
PHP can extend the program by using C ~ (?) C +.
PHP advantages:
Open source code
Free of charge
Quickness
Strong cross-platform
High efficiency
Graphic processing
object-oriented
Professional focus
Application of PHP technology:
Static page generation
Database caching
Process cache
Div+css W3C standard
Heavy load
Distributed system
Flex
Support for MVC
Smarty module engine
PHP certification 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 and var_dump
* echo and print are php statements, var_dump and print_r are functions * echo outputs one or more strings separated by commas, and no return value is a language structure rather than a real function, so it cannot be used as part of an expression. * print is also a keyword of php. A return value can only print the value of a simple type variable (such as int,string), and return true if the string is displayed successfully. Otherwise, if you return false* print_r, you can print out the values of complex type variables (such as arrays, objects) in the form of a list, starting with array and object, but the print_r output Boolean value and the result of NULL are meaningless, because both print "\ 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 for a detailed explanation of the HTTP status code
Common HTTP status codes:
200-request succeeded
301-Resources (web pages, etc.) are permanently escaped to other URL
404-the requested resource (web page, etc.) does not exist
505-Internal server error
HTTP status code classification:
1 request *-Information. The request received by the server requires the requestor to continue with the operation.
2successfully *-successful, the operation was received and processed successfully
3 please *-redirect, further action is required to complete the request
4 error *-client error, request containing syntax error or unable to complete the request
5error * Server error, server is in the process of processing request
An error has occurred in the
8. What are magic quotation marks
Magic quotation marks are a process that automatically escapes the data entered into the PHP script. It is best not to escape during coding but as needed at run time.
9. How to get the ip of the client (required to get an int) and the code of the server ip
Client: $_ SERVER ["REMOTE_ADDR"]; or getenv ('REMOTE_ADDR')
Ip2long for conversion
Server side: gethostbyname ('www.baidu.com')
10. Use those tools for version control
Cvs 、 svn 、 vss 、 git
11. The method of optimizing database
Eight ways of MySQL Database Optimization (Classical must see) Click to get
Select the most applicable field attribute, minimize the width of the defined field, and set the field to NOTNULL as much as possible. For example, "province" and "gender" are best suited to ENUM.
Use JOIN to replace subqueries
Apply UNION instead of manually created temporary tables
Transaction processing
Lock tables, optimize transaction processing
Suitable for foreign keys, optimize locking table
Build an index
Optimize query statement
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, and it was my first choice to use templates in this language. Although it is no longer updated frequently and lacks some of the features of the new generation of template engines, it is still worth seeing.
13. For high-traffic websites, what method should be adopted to solve the problem of traffic?
Confirm whether the server hardware can support the current traffic
Separation of database read and write and optimization of data table
The functional rules of the program prohibit external hotlinks
Control the download of large files
Use different hosts to divert major traffic
14. What is the difference between the statement include and require? To avoid including the same file multiple times, you can use (?) Sentence to replace them.
Require is included unconditionally, that is, if require is added to a process, require will be executed first regardless of whether the condition is true or not. 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 (probably because 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: require is fatal when the include file does not exist or syntax errors, but include is not
Require_once indicates that it is included only once, avoiding repeated inclusion
15. Talk about the understanding of mvc
An application program completed by a model, a view, and a controller in which the model sends the function to be implemented to the controller, and the controller receives the organization function and passes it to the view
16. Explain the difference between passing a value and passing a reference in php, and when to pass a reference?
Variables always pass values by default, that is, when the value of one expression is assigned to a variable, the value of the entire expression is assigned to the target variable, which means that 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 assignments. This means that the new variable simply references _ (in other words, becomes its alias or points to) the original variable. The new variable changed will affect the original variable, and vice versa. Using reference assignment, simply add a & symbol to the variable to be assigned (source variable)
Object is passed reference by default
For larger data, it is better to pass references, which can save memory overhead.
The above is all the contents of the article "what are the Classic interview questions for PHP". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.