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笔试题
Nov 11 面试题
编码实现字符串转整型的函数
Jun 02 面试题
阿尔卡特(中国)的面试题目
Aug 20 面试题
C++的几个面试题附答案
Aug 03 面试题
简述数据库的设计过程
Jun 22 面试题
开放系统互连参考模型
Jun 29 面试题
盛大二次面试题
Nov 18 面试题
优纳科技软件测试面试题
May 15 面试题
用Java语言将一个键盘输入的数字转化成中文输出
Jan 25 面试题
金鑫耀Java笔试题
Sep 06 面试题
什么是抽象
Dec 13 面试题
解释一下ruby中的特殊方法与特殊类
Feb 26 面试题
Yahoo的PHP面试题
May 26 #面试题
PHP数据运算类型都有哪些
Nov 05 #面试题
一套PHP的笔试题
May 31 #面试题
新浪网技术部笔试题
Aug 26 #面试题
如何处理简单的PHP错误
Oct 14 #面试题
PHP面试题及答案二
May 23 #面试题
PHP经典面试题
Sep 03 #面试题
You might like
PHP file_get_contents 函数超时的几种解决方法
2009/07/30 PHP
php报表之jpgraph柱状图实例代码
2011/08/22 PHP
php数组中包含中文的排序方法
2014/06/03 PHP
详解php的socket通信
2015/08/11 PHP
ThinkPHP3.2.3实现分页的方法详解
2016/06/03 PHP
php实现将数组或对象写入到文件的方法小结【三种方法】
2020/04/22 PHP
php+websocket 实现的聊天室功能详解
2020/05/27 PHP
javascript event 事件解析
2011/01/31 Javascript
node.js中的fs.futimes方法使用说明
2014/12/17 Javascript
原生javascript实现隔行换色
2015/01/04 Javascript
jQuery中$.ajax()和$.getJson()同步处理详解
2015/08/12 Javascript
深入剖析JavaScript编程中的对象概念
2015/10/21 Javascript
javascript实现很浪漫的气泡冒出特效
2020/09/05 Javascript
js在ie下打开对话窗口的方法小结
2016/10/24 Javascript
JavaScript中省略元素对数组长度的影响
2016/10/26 Javascript
详解JavaScript中数组的reduce方法
2016/12/02 Javascript
JS鼠标滚动分页效果示例
2017/07/05 Javascript
NodeJS收发GET和POST请求的示例代码
2017/08/25 NodeJs
vue自动化表单实例分析
2018/05/06 Javascript
Vue 组件参数校验与非props特性的方法
2019/02/12 Javascript
浅谈对于“不用setInterval,用setTimeout”的理解
2019/08/28 Javascript
JS算法教程之字符串去重与字符串反转
2020/12/15 Javascript
[06:36]吞吞映像top1
2014/06/20 DOTA
python使用urlparse分析网址中域名的方法
2015/04/15 Python
Python的dict字典结构操作方法学习笔记
2016/05/07 Python
Selenium(Python web测试工具)基本用法详解
2018/08/10 Python
Python XlsxWriter模块Chart类用法实例分析
2019/03/11 Python
python time.sleep()是睡眠线程还是进程
2019/07/09 Python
对django views中 request, response的常用操作详解
2019/07/17 Python
python实现京东订单推送到测试环境,提供便利操作示例
2019/08/09 Python
python 中xpath爬虫实例详解
2019/08/26 Python
小学优秀辅导员事迹材料
2014/05/11 职场文书
杨善洲观后感
2015/06/04 职场文书
怎样做好公众演讲能力?
2019/08/28 职场文书
在python中实现导入一个需要传参的模块
2021/05/12 Python
JS封装cavans多种滤镜组件
2022/02/15 Javascript