45fan.com - 路饭网

搜索: 您的位置主页 > 电脑频道 > 电脑教程 > 阅读资讯:PHP面试题集锦

PHP面试题集锦

2016-09-06 13:24:36 来源:www.45fan.com 【

PHP面试题集锦

公司近来——其实有半年了,在招聘PHP程序员,让我写了几个面试的题目。我就根据工作中经常碰到的问题列出了八个。要求被测试者仅用笔和纸完成代码。写出来的代码可能根本不能运行,但必须思路清晰。因为有的应聘者英文水平有待提高,所以又翻译成中文。

PHP TEST
1. Write a script in PHP and Javascript to accept two textarea's, slot and alternative by the name.
+ slot can contain many a lines, each line includes many words and is ended by a number
+ the chars in the slot can only be either alpha-numeric chars or squares or underlines
+ if a word in the slot is surrounded by underlines, it must start a new line in the alternatives, followed by the detailed definition of the word
+ the square brackets should come in pairs
for example, the following is legal slot and alternative:
SLOT ALTERNATIVE
---------------------- --------------------------
| this is 1 | | _this_ th ee s |
| the is 1 | | |
| this's 2 | | |
| _this_ 2 | | |
---------------------- --------------------------

2. A directory contains many a numbered sub-dir, and other files or directories as well. Each numbered sub-dir contains pictures(only jpg or png) and other files. Some of the pictures are original, while the others are the result of conversion from the original(jpg.jpg or png.png or jpg.png). Write a BASH command/script to list all those orphaned pictures whose original counterparts are missing.

3. There are two tables: students, and scores, in the mysql database (4.0+) exactly like this:

SN | Name SN | Score
------------- -------------
1 | Jerry 1 | 48
------------- -------------
2 | Lily 2 | 50
------------- -------------
3 | Roy
-------------
where the SN is the foreigh key. Write an SQL statement to delete all the names that have no score.

4. Make a function to print an HTML table of r rows and c cols; fill the cells with up to n consecutive numbers (if n is greater than the produce of r and c, discard the rest). Ensure that all rows have the same number of columns.

5. Write some bash commands to list all the php scripts (*.php) in the current directory and its sub-directory. Try to use as many different methods as possible.

6. Write a function to resize an image to be less than 660x570px. Be sure to keep the original ratio of width to height.

7. Write a script to reverse (interchange 1 with 0) the n-th bit of a m-bit binary number.

8. Use regex to remove all html tags from a file.

PHP 测试

1. 分别用PHP和Javascript来验证两个分别叫slot和alternative的文本框里面的内容:
+ slot可以包含许多行,每行又包含若干个单词,并且以数字结尾
+ slot中的每个单词只能由数字、字母、方括号和下划线构成
+ 如果slot中的某个单词前后各有相同书面的下划线,则这个单词必须在alternatives另起一行,并带有其定义
+ 方括号必须成对出现
例如,下面的slot和alternative是正确的:
SLOT ALTERNATIVE
---------------------- --------------------------
| this is 1 | | _this_ th ee s |
| the is 1 | | |
| this's 2 | | |
| _this_ 2 | | |
---------------------- --------------------------

2. 一个目录里面有若干个以数字命名的子目录和其他子目录。每个以数字命名的子目录里面有若干(JPG或者PNG格式的)图片以及其他文件。这些图片中有的是原始的图片,有的是从原始图片生成的(生成以后的扩展名是png.png或者jpg.jpg或者png.jpg)。使用BASH命令或者脚本删除哪些没有对应原始图片的导出图片。

3. 在一个mysql 4.0+的数据库中有两个表,学生表和成绩表,分别如下所示:

SN | Name SN | Score
------------- -------------
1 | Jerry 1 | 48
------------- -------------
2 | Lily 2 | 50
------------- -------------
3 | Roy
-------------
其中SN是联系两个表的外键。用带有LEFT JOIN的SQL语句删除哪些没有对应成绩的学生。
4. 用函数打印一个r行c列的HTML表格,并在单元格中依次填入前n个自然数。如果n大于单元格的总数,以单元格总数为准,去掉多余的部分。注意使得每行都有相同的单元格。
5. 用BASH和perl命令(脚本),列出当前目录及其子目录里面所有扩展名为.php的文件。尽量使用多种不同的方法。
6. 写一个函数,将一个图片缩放成大小不超过660x570px。注意保持长与宽的比例不变。
7. 用函数实现将一个m位二进制串中的第n位置反。
8. 用正则表达式除去一个文件中所有HTML标记。
 

本文地址:http://www.45fan.com/dnjc/73156.html
Tags: PHP 公司 试题
编辑:路饭网
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部