Home Backend Development PHP Tutorial PHP面试题基础有关问题

PHP面试题基础有关问题

Jun 13, 2016 pm 12:23 PM
client message server

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 of this Website
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

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to install, uninstall, and reset Windows server backup How to install, uninstall, and reset Windows server backup Mar 06, 2024 am 10:37 AM

WindowsServerBackup is a function that comes with the WindowsServer operating system, designed to help users protect important data and system configurations, and provide complete backup and recovery solutions for small, medium and enterprise-level enterprises. Only users running Server2022 and higher can use this feature. In this article, we will explain how to install, uninstall or reset WindowsServerBackup. How to Reset Windows Server Backup If you are experiencing problems with your server backup, the backup is taking too long, or you are unable to access stored files, then you may consider resetting your Windows Server backup settings. To reset Windows

How to use element-plus to call message in vue3 How to use element-plus to call message in vue3 May 17, 2023 pm 03:52 PM

vue3 uses element-plus to call the message environment: vue3+typescript+element-plus1. After the global introduction of element, element has added the global method $message in app.config.globalProperties, so you can use mounted(){(thisasany) directly in the optionsAPI. $message.success("this.$message");}2. In the compositionAPI, the setup method passes in two variables props and

Windows Server 2025 preview version welcomes update, Microsoft improves Insiders testing experience Windows Server 2025 preview version welcomes update, Microsoft improves Insiders testing experience Feb 19, 2024 pm 02:36 PM

On the occasion of releasing the build 26040 version of Windows Server, Microsoft announced the official name of the product: Windows Server 2025. Also launched is the Windows11WindowsInsiderCanaryChannel version build26040. Some friends may still remember that many years ago someone successfully converted Windows NT from workstation mode to server mode, showing the commonalities between various versions of Microsoft operating systems. Although there are clear differences between Microsoft's current version of the server operating system and Windows 11, those who pay attention to the details may be curious: why Windows Server updated the brand,

How to modify the Nginx version name to disguise any web server How to modify the Nginx version name to disguise any web server May 14, 2023 pm 09:19 PM

How to modify the default name of nginx, you can disguise it a little, or you can install Tip: Generally, modifications are made before nginx is compiled. After modification, the code needs to be recompiled as follows: scr/core/nginx.conf#definenginx_version"1.4.7"#definenginx_ver"nginx/"n

Microsoft releases Windows Server vNext preview version 25335 Microsoft releases Windows Server vNext preview version 25335 Jan 10, 2024 am 08:49 AM

While Microsoft released the Win11 preview update for the desktop, today it also released the Windows Server Long Term Service Channel (LTSC) preview Build 25335. As usual, Microsoft did not publish a complete change log, or even provide a corresponding blog post. Microsoft has adjusted the Windows Server preview version update log to make it the same as the Canary channel version. If no new content is introduced, the official blog post will not be posted. Note from IT Home: The server brand has not been updated and is still Windows Server 2022 in the preview version. In addition, Microsoft calls these versions Windows Server vNext instead of the Windows version that is already on the market.

Microsoft releases Windows Server 26080 preview update: Fixes Feedback Hub failure Microsoft releases Windows Server 26080 preview update: Fixes Feedback Hub failure Mar 14, 2024 pm 07:11 PM

IT House reported on March 14 that in addition to the Windows 11 Build 26080 preview update for the desktop, Microsoft also updated and launched the Windows Server Build 26080 preview update. As the latest preview version of the upcoming Windows Server Long Term Servicing Channel (LTSC), Windows Server Build 26080 provides Data Center Edition and Standard Edition, and users can choose desktop experience and Server Core installation options. This release also includes an annual channel for container hosts, and an Azure release specifically for virtual machine evaluation. IT House queries X social media. User feedback clicks the Copilot button in the lower right corner.

What is the matching logic of Server and Location in Nginx? What is the matching logic of Server and Location in Nginx? May 12, 2023 am 11:10 AM

Server matching logic When nginx determines which server block to execute a request, it mainly focuses on the listen and server_name fields in the server block. The listen command listen field defines the IP and port of the server response. If the listen field is not explicitly configured, the default listening 0.0.0.0:80 (root) or 0.0.0.0:8080 (non-root) listen can be configured as: a combination of ip and port, a single ip, listening on port 80 by default, a single port, and listening on all ip interfaces by default A unixsocket path where the last entry is usually only used in different

Steps to install GNOME 3 on Ubuntu Server 11.04 Steps to install GNOME 3 on Ubuntu Server 11.04 Dec 31, 2023 pm 03:59 PM

If you think there is no need to install a graphical interface when installing Ubuntu Server 11.04, let alone GNOME 3, which is not yet complete. . Or it should be built with ARCH+GNOME3. So please don't waste your time reading any more. It took 2 nights and a day and reinstalled N times. Finally something has come of it. It's not easy. Without further ado, let’s get to the point: Hardware: One ThinkPad (For X61) 2. Enter the boot options interface, select USB boot, and then choose to install Ubu

See all articles