PHP笔试题2
PHP笔试题2
2011年04月24日
说在前面:
1、以下题目,除了编程任务外其他都需要写在给你提供的草纸上。纸张是珍贵的地球资源,请节约使用。编程任务在有相应的环境时,会要求上机书写,实在没有条件,就只能写在草纸上了。
2、时间:
基础任务+进阶任务+设计任务 = 90分钟
编程任务 = 60分钟
基础任务:
1、请列举你能想到的UNIX信号,并说明信号用途。
2、请列举、你能想到的所有的字符串查找算法,并加注释简单说明。
3、有一个IP地址(192.168.0.1),请写出其32位无符号整数形式。
4、写出、你能想到的所有HTTP返回状态值,并说明用途(比如:返回404表示找不到页面)
基础任务-选作(会得到额外分数):
1、画几个你最熟悉的SERVER端模型出来(格式不重要,尽量将图画清楚,说明思路即可)
进阶任务:
1、PHP的垃圾收集机制是怎样的?
说明:
1)如果,你熟悉PHP源码,那么请从源码入手,回答些问题,会获得额外加分
2)如果,你不熟悉PHP源码,那么尽你所能,多写点东西,包括利用自己的编程直觉得到的信息,都可以。
3)对,则有分,错误不扣,不写无分。
2、请写出HTTP头,并符合以下要求:
1)这是一个post请求
2)目标:http://www.example.com:8080/test
3)POST变量:
username: test
pwd: test2
intro: Hello world!
4)包含以下COOKIE信息:
cur_query: you&me
说明:
1)如果,你记不得某个HTTP协议中的指令字了,那么,无奈这举是用"汉字"代替。
2)如果,你能记住更多的HTTP协议指令字,那么多写几句,总是没坏处,对吧?
3)最关键的,只需要画出正确的"轮廓"(还记得httpwatch等工具打印出来的头部吗?那就是"轮廓"的含义),也会有分数,但如果,连"轮廓"都写错了,那么就很遗憾了。
设计任务:
1、最近总有人骚扰我们的投票模块,需要你来设计一个投票限制的东东
要求如下:
1)要求每个QQ号码(假设此QQ号码在UNIT32内可以表示)10分钟这内只能投5票。
2)我们的用户很踊跃,平均每天要有2000万人左右通过此程序投票。
说明:
1)无需写代码,只需要图跟文字即可。
2)对于关键逻辑,请用图加代码表示出来,这也是对你文字表达能力的一个考验。
3)对你能想到的所有的边界条件列出来,这是对你逻辑思维全面与敏捷性的考验。
4)存储部分,尽你所能吧。如果,你需要一个自己设计的存储层,那么把这个存储层的实现,用文字+图片方式描述清楚,要是设计合理,你会获得华丽的奖分。
编程任务:
1、我们碰到了*烦,一个新来的传教士惹恼了上帝,上帝很愤怒,要求我们把圣经(bbe.txt)背熟,直至他说哪个单词,我们就要飞快的回答出这个单词在第几行第几个单词位置。听说你是个优秀的程序员,那么髟助我们完成这个不可能的任务吧。
要求如下:
1)/myworks/example/bbe.txt,98版本英文圣经一本
2)输入部分要求如下:php ./example.php [单词]
3)输出部分如下:[单词] 1,2 2,4 5,6 表示:此单词在1行2列(第二个单词),2行4列...
说明:
1)此文本4MB之巨...
2)单词的含义:由英文字母(大小写),数字(0-9)组成的串
3)提供给你的机器OS为ubuntu 9.10,内存只有1G,而且,很不幸的,其中700M用来做了别的
4)上机考试不允许上网,但我装了man文档以及读取CHM以及PDF的阅读器,在电脑的桌面的CHM文件夹中,有相应的PHP参考手册
5)算法复杂度要求不能大于O(N^2)(就是N的平方)
6)什么?PHP低效且用起来不顺手,好的,你可以用别的语言来实现。但注意:提供给你的机器上只有python 2.4/perl 5.8/gcc[g++] 4.1
=============
1.在PHP中,当前脚本的名称(不包括路径和查询字符串)记录在预定义变量(1)中;而链接到当前页面的URL记录在预定义变量(2)中。
2.执行程序段将输出(3)。
3.在HTTP 1.0中,状态码 401 的含义是(4);如果返回"找不到文件"的提示,则可用 header 函数,其语句为(5)。
4.数组函数 arsort 的作用是(6);语句 error_reporting(2047)的作用是(7)。
5.PEAR中的数据库连接字符串格式是(8)。
6.写出一个正则表达式,过虑网页上的所有JS/VBS脚本(即把标记及其内容都去掉):(9)。
7.以Apache模块的方式安装PHP,在文件http.conf中首先要用语句(10)动态装载PHP模块,
然后再用语句(11)使得Apache把所有扩展名为php的文件都作为PHP脚本处理。
8.语句 include 和 require 都能把另外一个文件包含到当前文件中,它们的区别是(12);为了避免多次包含同一文件,可以用语句(13)来代替它们。
9.类的属性可以序列化后保存到 session 中,从而以后可以恢复整个类,这要用到的函数是(14)。
10.一个函数的参数不能是对变量的引用,除非在php.ini中把(15)设为on.
11.SQL 中LEFT JOIN的含义是(16)。
如果 tbl_user记录了学生的姓名(name)和学号(ID),
tbl_score记录了学生(有的学生考试以后被开除了,没有其记录)的学号(ID)和考试成绩(score)以及考试科目(subject),
要想打印出各个学生姓名及对应的的各科总成绩,则可以用SQL语句(17)。
12.在PHP中,heredoc是一种特殊的字符串,它的结束标志必须(18)。
13.写一个函数,能够遍历一个文件夹下的所有文件和子文件夹。
14.简述论坛中无限分类的实现原理。
15.设计一个网页,使得打开它时弹出一个全屏的窗口,该窗口中有一个文本框和一个按钮。用户在文本框中输入信息后点击按钮就可以把窗口关闭,而输入的信息却在主网页中显示。
答案(填空):
1. echo $_SERVER[''PHP_SELF'']; echo $_SERVER["HTTP_REFERER"];
2. 0
3. (4)未授权 (5) header("HTTP/1.0 404 Not Found");
4. (6)对数组进行逆向排序并保持索引关系 (7)All errors and warnings
5. 没弄明白
6. /].*?>.*?/si
7.(10) LoadModule php5_module "D:/xampp/apache/bin/php5apache2.dll"
(11) AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml
8.(12) 发生异常时include产生警告require产生致命错误 (13) require_once()/include_once()
9. serialize() /unserialize()
10. allow_call_time_pass_reference
11. (16) 自然左外连接
(17) select name , count(score) as sum_score from tbl_user left join tbl_score on tbl_user.ID=tbl_score.ID group by tbl_user.ID
12. 结束标识符所在的行不能包含任何其它字符除";"
13.
/**
* 遍历目录,结果存入数组。支持php4及以上。php5以后可用scandir()函数代替while循环。
* @param string $dir
* @return array
*/
my_scandir($dir)
{
$files = array();
if ( $handle = opendir($dir) )
{
while ( ($file = readdir($handle)) !== false )
{
if ( $file != ".." && $file != "." )
{
if ( is_dir($dir . "/" . $file) )
{
$files[$file] = rec_scandir($dir . "/" . $file);
}
else
{
$files[] = $file;
}
}
}
closedir($handle);
return $files;
}
}

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)