search
Homephp教程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("");

}

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
2023年前端React面试题大汇总(收藏)2023年前端React面试题大汇总(收藏)Aug 04, 2020 pm 05:33 PM

php中文网作为知名编程学习网站,为您整理了一些React面试题,帮助前端开发人员准备和清除React面试障碍。

2023年精选Web前端面试题大全及答案(收藏)2023年精选Web前端面试题大全及答案(收藏)Apr 08, 2021 am 10:11 AM

本篇文章给大家总结一些值得收藏的精选Web前端面试题(附答案)。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

五个常见的Go语言面试题及解答五个常见的Go语言面试题及解答Jun 01, 2023 pm 08:10 PM

作为近年来备受热捧的一门编程语言,Go语言已经成为众多公司与企业的面试热点。对于Go语言初学者而言,在面试过程中遇到相关问题时,如何回答是一个值得探讨的问题。下面列举五个常见的Go语言面试题及解答,供初学者参考。请介绍一下Go语言的垃圾回收机制是如何工作的?Go语言的垃圾回收机制基于标记-清除算法和三色标记算法。当Go程序中的内存空间不够用时,Go垃圾回收器

50个你必须掌握的Angular面试题(收藏)50个你必须掌握的Angular面试题(收藏)Jul 23, 2021 am 10:12 AM

本篇文章给大家分享50个必须掌握的Angular面试题,会从初学者-中级-高级三个部分来解析这50个面试题,带大家吃透它们!

面试官:你对高并发了解多少?我:emmm...面试官:你对高并发了解多少?我:emmm...Jul 26, 2023 pm 04:07 PM

高并发,几乎是每个程序员都想拥有的经验。原因很简单:随着流量变大,会遇到各种各样的技术问题,比如接口响应超时、CPU load升高、GC频繁、死锁、大数据量存储等等,这些问题能推动我们在技术深度上不断精进。

2023年vue高频面试题分享(附答案分析)2023年vue高频面试题分享(附答案分析)Aug 01, 2022 pm 08:08 PM

本篇文章给大家总结一些值得收藏的2023年精选vue高频面试题(附答案)。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

总结一些前端常见面试题(附答案),带你巩固知识点!总结一些前端常见面试题(附答案),带你巩固知识点!Jul 29, 2022 am 09:49 AM

发布文章主要也是巩固自己的知识更加熟练,全凭自己的理解和网上查资料总结出来的,如有不对的地方还望多多指点。下面是我总结的一下常见面试题,为了督促自己还可以会继续更新

看看这些前端面试题,带你搞定高频知识点(四)看看这些前端面试题,带你搞定高频知识点(四)Feb 20, 2023 pm 07:19 PM

每天10道题,100天后,搞定所有前端面试的高频知识点,加油!!!,在看文章的同时,希望不要直接看答案,先思考一下自己会不会,如果会,自己的答案是什么?想过之后再与答案比对,是不是会更好一点,当然如果你有比我更好的答案,欢迎评论区留言,一起探讨技术之美。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),