PHP面试题附答案


Posted in 面试题 onNovember 28, 2015
1. Which of the following will not add john to the users array?
1. $users[] = ‘john’;
2. array_add($users,’john’);
3. array_push($users,’john’);
4. $users ||= ‘john’;
Answer: 2,4
2. What’s the difference between sort(), asort() and ksort(),rsort()? Under what circumstances would you use each of these?
sort(): 本函数对数组的值进行排序。当本函数结束时数组单元将被从最低到最高重新安排,array 中的单元赋予新的键名。这将删除原有的键名而不仅是重新排序。
asort(): 这个函数将数组的值重新排序,由小至大排列。数组的索引亦跟着值的 顺序而变动。当您在程序中需要重新整理数组值的 顺序时,就可以使用这个函数。
ksort(): 对数组按照键名排序,保留键名到数据的关联。本函数主要用于关联数组。
rsort(): 本函数对数组进行逆向排序(最高到最低)。与sort()执行相反的操作。
3. What would the following code print to the browser? Why?
$num = 10;
function multiply(){
$num = $num * 10;
}
multiply();
echo $num;
10
4. What is the difference between a reference and a regular variable? How do you pass by reference & why would you want to?
pass by reference like this functions(&$vars);
it likes more fast;
5. What functions can you use to add library code to the currently running script?
inlcude() or require();
6. What is the difference between foo() & @foo()?
if foo() throw a error, will be alert, but @foo() no;
7. How do you debug a PHP application?
xdebug or use die() do it;
8. What does === do? What’s an example of something that will give true for ‘==’, but not ‘===’?
=== 用于精确比较 ex: (” == null) => true but ( ”===null) =>false;
9. How would you declare a class named “myclass” with no methods or properties?
class myclass{
}
10. How would you create an object, which is an instance of “myclass”?
$myoject = new myclass();
11. How do you access and set properties of a class from within the class?
getVar() or setVar() ;
12. What is the difference between include & include_once? include & require?
require:PHP 程式在执行前,就会先读入 require 所指定引入的档案,使它变成 PHP 程式网页的一部份。常用的函式,亦可以这个方法将它引入网页中。错误产生致命错误。
include:这个函式一般是放在流程控制的处理区段中。PHP 程式网页在读到 include 的档案时,才将它读进来。这种方式,可以把程式执行时的流程简单化。错误产生警报。
include_once:此行为和include()语句类似,唯一区别是如果该文件中的代码已经被包含了,则不会再次包含。如同此语句名字暗示的那样,只会包含一次。
13. What function would you use to redirect the browser to a new page?
1. redir()
2. header()
3. location()
4. redirect()
2
14. What function can you use to open a file for reading and writing?
1. fget();
2. file_open();
3. fopen();
4. open_file();
3
15. What’s the difference between mysql_fetch_row() and mysql_fetch_array()?
mysql_fetch_row():返回根据所取得的行生成的数组,如果没有更多行则返回 FALSE。
mysql_fetch_array(): 是mysq_fetch_row()的扩展版本。除了将数据以数字索引方式储存在数组中之外,还可以将数据作为关联索引储存,用字段名作为键名。
16. What does the following code do? Explain what’s going on there.
$date=’08/26/2003′;
print ereg_replace(‘([0-9]+)/([0-9]+)/([0-9]+)’,’2/1/3′,$date);
本函数以 正则 的规则来解析比对字符串 ,欲取而代之的字符串为’2/1/3′。
返回值为字符串类型,为取代后的字符串结果。
17. Given a line of text $string, how would you write a regular expression to strip all the HTML tags from it?
strip_tags
18. What’s the difference between the way PHP and Perl distinguish between arrays and hashes?
19. How can you get round the stateless nature of HTTP using PHP?
20. What does the GD library do?
21. Name a few ways to output (print) a block of HTML code in PHP?
22. Is PHP better than Perl? – Discuss.
如果成功则返回 TRUE,失败则返回 FALSE。

Tags in this post...

面试题 相关文章推荐
康拓普公司Java笔面试
Sep 23 面试题
List, Set, Map是否继承自Collection接口?
May 16 面试题
一套C++笔试题面试题
Jun 06 面试题
android面试问题与答案
Dec 27 面试题
什么是SQL Server的确定性函数和不确定性函数
Aug 04 面试题
逻辑链路控制协议
Oct 01 面试题
上海微创软件面试题
Jun 14 面试题
在c#中using和new这两个关键字有什么意义
May 19 面试题
Linux Interview Questions For software testers
Jun 02 面试题
线程问题:wait()方法是定义在哪个类里面
Jul 07 面试题
final, finally, finalize的区别
Mar 01 面试题
Structs界面控制层技术
Oct 11 面试题
Yahoo的PHP面试题
May 26 #面试题
PHP数据运算类型都有哪些
Nov 05 #面试题
一套PHP的笔试题
May 31 #面试题
新浪网技术部笔试题
Aug 26 #面试题
如何处理简单的PHP错误
Oct 14 #面试题
PHP面试题及答案二
May 23 #面试题
PHP经典面试题
Sep 03 #面试题
You might like
PHP6 先修班 JSON实例代码
2008/08/23 PHP
php下几个常用的去空、分组、调试数组函数
2009/02/22 PHP
PHP单例模式详细介绍
2015/07/01 PHP
php socket通信(tcp/udp)实例分析
2016/02/14 PHP
javascript css在IE和Firefox中区别分析
2009/02/18 Javascript
网站404页面3秒后跳到首页的实例代码
2013/08/16 Javascript
js设置cookie过期当前时间减去一秒相当于立即过期
2014/09/04 Javascript
浅析Nodejs npm常用命令
2016/06/14 NodeJs
基于angularJS的表单验证指令介绍
2016/10/21 Javascript
JavaScript获取服务器时间的方法详解
2016/12/11 Javascript
vue.js学习之UI组件开发教程
2017/07/03 Javascript
WdatePicker.js时间日期插件的使用方法
2017/07/26 Javascript
JS实现按钮添加背景音乐示例代码
2017/10/17 Javascript
vue-cli常用设置总结
2018/02/24 Javascript
vue.js给动态绑定的radio列表做批量编辑的方法
2018/02/28 Javascript
vue 移动端适配方案详解
2018/11/15 Javascript
JavaScript ES2019中的8个新特性详解
2019/02/20 Javascript
vue 实现LED数字时钟效果(开箱即用)
2019/12/08 Javascript
vue 实现websocket发送消息并实时接收消息
2019/12/09 Javascript
JavaScript享元模式原理与用法实例详解
2020/03/09 Javascript
PYTHON压平嵌套列表的简单实现
2016/06/08 Python
手把手教你python实现SVM算法
2017/12/27 Python
python 3利用Dlib 19.7实现摄像头人脸检测特征点标定
2018/02/26 Python
使用Python实现企业微信的自动打卡功能
2019/04/30 Python
简单了解Python write writelines区别
2020/02/27 Python
详解python中的三种命令行模块(sys.argv,argparse,click)
2020/12/15 Python
中国双语服务优势的在线购票及活动平台:247tickets
2018/10/26 全球购物
应届毕业生自荐信例文
2014/02/26 职场文书
高效课堂标语
2014/06/26 职场文书
2014普法依法治理工作总结
2014/12/18 职场文书
申报材料格式
2014/12/30 职场文书
2015年打非治违工作总结
2015/04/02 职场文书
小学生安全教育主题班会
2015/08/12 职场文书
90行Python代码开发个人云盘应用
2021/04/20 Python
python通配符之glob模块的使用详解
2021/04/24 Python
浅谈自定义校验注解ConstraintValidator
2021/06/30 Java/Android