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...

面试题 相关文章推荐
J2SDK1.5与J2SDK5.0有什么区别
Sep 19 面试题
说说你所熟悉或听说过的j2ee中的几种常用模式?及对设计模式的一些看法
May 24 面试题
如何设置Java的运行环境
Apr 05 面试题
是否有自动比较结构的方法
Jun 03 面试题
一套C++笔试题面试题
Jun 06 面试题
使用索引(Index)有哪些需要考虑的因素
Oct 19 面试题
什么是重载?CTS、CLS和CLR分别做何解释
May 06 面试题
C#笔试题集合
Jun 21 面试题
C#软件工程师英语面试题
Jun 07 面试题
Solaris操作系统的线程机制
Dec 23 面试题
数据库测试通常都包括哪些方面
Nov 30 面试题
介绍下java.util.Arrays类
Oct 16 面试题
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 备份数据库代码(生成word,excel,json,xml,sql)
2013/06/23 PHP
curl不使用文件存取cookie php使用curl获取cookie示例
2014/01/26 PHP
php对关联数组循环遍历的实现方法
2015/03/13 PHP
ExtJS 2.0实用简明教程 之Ext类库简介
2009/04/29 Javascript
一些mootools的学习资源
2010/02/07 Javascript
js比较和逻辑运算符的介绍
2013/03/10 Javascript
jquery 多行文本框(textarea)高度变化
2013/07/03 Javascript
JavaScript控制listbox列表框的项目上下移动的方法
2015/03/18 Javascript
javascript小数精度丢失的完美解决方法
2016/05/31 Javascript
使用Bootstrap打造特色进度条效果
2017/05/02 Javascript
Node.js实现发送邮件功能
2017/11/06 Javascript
浅谈vue-router2路由参数注意的问题
2017/11/08 Javascript
微信小程序+腾讯地图开发实现路径规划绘制
2019/05/22 Javascript
vue-form表单验证是否为空值的实例详解
2019/10/29 Javascript
python实现k均值算法示例(k均值聚类算法)
2014/03/16 Python
Python的面向对象思想分析
2015/01/14 Python
python通过floor函数舍弃小数位的方法
2015/03/17 Python
Linux RedHat下安装Python2.7开发环境
2017/05/20 Python
Python实现将HTML转换成doc格式文件的方法示例
2017/11/20 Python
Python 处理图片像素点的实例
2019/01/08 Python
Python多线程原理与用法实例剖析
2019/01/22 Python
Python中判断子串存在的性能比较及分析总结
2019/06/23 Python
python中类与对象之间的关系详解
2020/12/16 Python
Html5获取高德地图定位天气的方法
2019/12/26 HTML / CSS
Osklen官方在线商店:巴西服装品牌
2019/04/25 全球购物
食品营养与检测应届生求职信
2013/11/08 职场文书
初入社会应届生求职信
2013/11/18 职场文书
安全生产实施方案
2014/02/23 职场文书
财产公证书
2014/04/10 职场文书
三月学雷锋月活动总结
2014/04/28 职场文书
大学军训自我鉴定大全
2014/09/18 职场文书
呼兰河传读书笔记
2015/06/30 职场文书
《分数乘法》教学反思
2016/02/24 职场文书
Dashboard管理Kubernetes集群与API访问配置
2022/04/01 Servers
Win11安全功能升级:内置防网络钓鱼功能
2022/04/08 数码科技
为什么MySQL8新特性会修改自增主键属性
2022/04/18 MySQL