您好,欢迎访问一九零五行业门户网

PHP面试题基础问题,php面试题_PHP教程

php面试题基础问题,php面试题1.对于大流量的网站,您采用什么样的方法来解决访问量问题?
首先,确认服务器硬件是否足够支持当前的流量
其次,优化数据库访问。
第三,禁止外部的盗链。
第四,控制大文件的下载。
第五,使用不同主机分流主要流量。
第六,使用流量分析统计软件。
2.用php写出显示客户端ip与服务器ip的代码:
//显示客户端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')) {
$client_ip = getenv('remote_addr');
} else {
$client_ip = $http_server_var['remote_addr'];
}
return $client_ip;
}
//服务器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编程面试题。
(1) 某内容管理系统中,表message有如下字段:
id 文章id
title 文章标题
content 文章内容
category_id 文章分类id
hits 点击量
创建上表,写出mysql语句:
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)同样上述新闻发布系统:表comment记录用户回复内容,字段如下:
comment_id 回复id
id 文章id,关联message表中的id
comment_content 回复内容
现通过查询数据库需要得到以下格式的文章标题列表,并按照回复数量排序,回复最高的排在最前面
文章id 文章标题 点击量 回复数量
用一个sql语句完成上述查询,如果文章没有回复则回复数量显示为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)上述内容管理系统,表category保存分类信息,字段如下 (3分)
category_id int(4) not null auto_increment;
categroy_name varchar(40) not null;
用户输入文章时,通过选择下拉菜单选定文章分类
写出如何实现这个下拉菜单
function categorylist()
{
$result=mysql_query(select category_id,categroy_name from category)
or die(invalid query: . mysql_error());
print();
}
http://www.bkjia.com/phpjc/1048762.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/1048762.htmltecharticlephp面试题基础问题,php面试题 1.对于大流量的网站,您采用什么样的方法来解决访问量问题? 首先,确认服务器硬件是否足够支持当前的流量...
其它类似信息

推荐信息