Php interview questions (2)

Source: Internet
Author: User
The php interview questions collected on the Internet are posted for you in the php tutorial!

 

I. Basic Questions

 

1. What is object-oriented? What are the main features?

 

A face object is an elegant method to directly map objects and concepts in nature to the program world!

 

Main features: abstraction, inheritance, encapsulation, and Polymorphism

 

2. What is the difference between a SESSION and a COOKIE? Please refer to the protocol, the cause and effect of the SESSION?

 

Session is a solution for the server to save the client status information. It is generally stored in the server memory, and the session timeout time is set on the server.

 

Cookie is a solution for saving information on the client. It is generally saved as a file, and the cookie clearing time is set in the client browser.

 

3. What are the meanings of codes 302, 403, and 500 in HTTP status?

 

302: the temporary transfer is successful. The requested content has been transferred to a new location.

 

403: Access prohibited

 

500: Internal Server Error

 

4. Create a compressed package in Linux and decode the compressed package.

 

Tar-cvf demo.tar demo

 

Tar-xcf demo.tar

 

5. write out the meaning of the Data Type (int char varchar datetime text). What is the difference between varchar and char?

 

Int integer

 

Char fixed length character

 

Varchar variable-length characters

 

Datetime date type

 

Text

 

Differences between Varchar and char

 

Char is a character type with a fixed length. How much space is allocated will take up.

 

Varchar is a variable-length character type. It can effectively save space when the content is large.

 

Because the varchar type is variable, when the Data Length changes, the server must perform additional operations, so the efficiency is lower than that of the char type.

 

6. What are the basic differences between MyISAM and InnoDB?

 

The MyISAM type does not support advanced processing such as transaction processing, whereas the InnoDB type does. MyISAM tables emphasize performance, which is faster than InnoDB, but do not support transactions. InnoDB provides advanced database functions such as transaction support and external keys.

 

7. Do not use cookies to send a cookie to the client.

 

Understanding: When session_start () is enabled, a constant SID is generated. When the COOKIE is enabled, this constant is null. When the COOKIE is disabled, the PHPSESSID value is stored in this constant. Add a SID parameter after the URL to pass the SESSIONID value, so that the values in the SESSION can be used on the client page.

 

When the COOKIE is enabled on the client and the SESSION is enabled on the server.

 

When the browser requests for the first time, the server sends a COOKIE to the browser to store the SESSIONID.

 

When the browser sends the second request, the existing COOKIE is submitted to the server.

 

10. difference between isset () and empty (). The result of judging different data is $ a = 0; $ a = '0'; $ a = ''; $ a = false; $ a = null;

 

If Isset () is used to determine whether the existence exists, it is true, whether it is false or not.

 

Empty () determines whether it is null. If it is null, it is a true value. If it does not exist, it is also a true value.

 

Isset (): true; false

 

Empty (): true; true

 

12. How to pass variables between pages?

 

Get, post

 

Ii. Code questions

 

1. Write the regular expression that matches the URL.

 

/^ [A-zA-z] +: \/(\ w + (-\ w + )*)(\. (\ w + (-\ w + )*))*(\? \ S *)? /

 

2. Write out common sorting algorithms and use PHP to perform Bubble sorting. Sort the array $ a = array () in ascending order.

 

$ Arr = array (233,5, 6,75454, 32 );

 

Mao ($ arr );

 

Function mao ($ arr ){

 

$ N = count ($ arr );

 

For ($ I = 0; $ I <$ n; $ I ++ ){

 

For ($ j = $ n-1; $ j> 0; $ j --){

 

If ($ arr [$ J-1]> $ arr [$ j]) {

 

$ T = $ arr [$ J-1];

 

$ Arr [$ J-1] = $ arr [$ j];

 

$ Arr [$ j] = $ t;

 

}

 

}

 

}

 

}

 

3. In the test database, the student table has the following fields: name, class, and score. Name, class, and score respectively.

 

1) The students in each class are sorted in descending order of their scores;

 

2) Check the number of passing students and the number of failing students in each class. The format is class, number of passing students, and number of failing students;

 

3) Use PHP to write data to the connected database ("localhost", "msuser", "mspass"), execute the preceding SQL statements, display results, identify errors, and close the database;

 

1) SELECT * FROM student order by score desc;

 

3)

 

<? Php

 

$ Conn = mysql_connect ('localhost', 'root', '123 ');

 

@ Mysql_select_db ('test ');

 

$ SQL = "";

$ Result = mysql_query ($ SQL );

If ($ result & mysql_affected_rows ()){

.............................

}

Mysql_close ($ conn );

?>

-

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.