1. For websites with large traffic, what method do you use to solve the traffic problem?
First, confirm whether the server hardware is sufficient to support the current traffic
Second, optimize database access.
Third, external hotlinking is prohibited.
Fourth, control the download of large files.
Fifth, use different hosts to divert the main traffic.
Sixth, use traffic analysis and statistics software.
2. Use PHP to write the code to display the client IP and server IP:
//Display the client IP
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')) {
$cl ient_ip = getenv('REMOTE_ADDR');
} else {
$client_ip = $HTTP_SERVER_VAR['REMOTE_ADDR'];
}
return $client_ip;
}
//Server IP
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 interview questions.
(1) In a content management system, the message table has the following fields:
id article id
title article title
content article content
category_id article category id
hits clicks
Create the above table and write Exit 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) Same as the above news release system: table comment records user reply content, the fields are as follows:
comment_id reply id
id article id, associated with the id in the message table
comment_content reply content
Now we need to get a list of article titles in the following format by querying the database, and sort them by the number of replies, with the highest reply at the top
Article id Article title clicks and number of replies
Use a SQL statement to complete the above query. If the article has no replies, the number of replies will be displayed as 0
SELECT message.id id,message.title 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) The above content management system, table category saves classification information, the fields are as follows (3 points)
category_id int(4) not null auto_increment;
categroy_name varchar(40) not null;
When the user enters an article, the article category is selected by selecting the drop-down menu
Write 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 introduces the basic questions of PHP interview questions, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.