Basic questions about PHP interview questions

Source: Internet
Author: User
: This article mainly introduces the basic questions about PHP interview questions. if you are interested in PHP tutorials, please refer to them. 1. What methods do you use to solve the traffic issue for websites with large traffic volumes?

First, check whether the server hardware is sufficient to support the current traffic.

Second, optimize database access.

Third, prohibit external leeching.

Fourth, control the download of large files.

Fifth, use different hosts to distribute major traffic.

Sixth, use the traffic analysis and statistics software.

2. use PHP to write the code that shows the client IP address and server IP address:

// Display the client IP address

Function get_client_ip (){#

If (getenv ('http _ CLIENT_IP ')){

$ Client_ip = getenv ('http _ CLIENT_IP ');

} Elseif (getenv ('http _ X_FORWARDED_FOR ')){

$ Client_ip = getenv ('http _ X_FORWARDED_FOR ');

} Elseif (getenv ('remote _ ADDR ')){

$ Client_ip = getenv ('remote _ ADDR ');

} Else {

$ Client_ip = $ HTTP_SERVER_VAR ['remote _ ADDR '];

}

Return $ client_ip;

}

// Server IP address

Function get_server_ip (){

If (isset ($ _ SERVER ))

{

If ($ _ SERVER ['server _ ADDR ']) $ huoqu_ip = $ _ SERVER ['server _ ADDR'];

Else $ huoqu_ip =$ _ SERVER ['Local _ ADDR '];

}

Else

{

$ Huoqu_ip = getenv ('server _ ADDR ');

}

Return $ huoqu_ip;

}

3. MYsql programming questions.

(1) in a content management system, the table message has the following fields:

Id article id

Title article title

Content

Category_id document Category id

Hits clicks

Create the table above and write the MySQL statement:

Create table 'message '(

Id int (11) not null auto_increment,

Title varchar (200) default NULL,

Content blob,

Category_id int (11) default NULL,

Hits int (11) default NULL,

Primary key ('id ')

) ENGINE = InnoDB default charset = utf8;

(2) Similarly, the above-mentioned news publishing system: the table comment records the user's reply content. The fields are as follows:

Comment_id reply id

Id document id, associated with the id in the message Table

Comment_content reply content

To query the database, you need to obtain a list of article titles in the following format and sort them by the number of replies.

Article id: number of replies in the document title

Use an SQL statement to complete the above query. if the article does not reply, the number of replies is displayed as 0.

SELECT message. id, message. title, IF (message. 'hits 'is null, 0, message. 'hits ')

Hits, IF (comment. 'id' is NULL, 0, count (*) number

FROM message left join comment ON message. id = comment. id

Group by message. 'id'

(3) in the preceding content management system, Table category stores the category information. The fields are as follows (3 points)

Category_id int (4) not null auto_increment;

Categroy_name varchar (40) not null;

When you enter an article, select an article category from the drop-down menu.

Write down how to implement this drop-down menu

Function categoryList ()

{

$ Result = mysql_query ("select category_id, categroy_name from category ")

Or die ("Invalid query:". mysql_error ());

Print ("");

}

The above describes the basic questions about PHP interview questions, including some content, and hope to help those who are interested in PHP tutorials.

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.