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

面试题 相关文章推荐
PHP中如何创建和修改数组
May 02 面试题
PHP如何去执行一个SQL语句
Mar 05 面试题
介绍Ibatis的核心类
Nov 18 面试题
请写一个C函数,若处理器是Big_endian的,则返回0;若是Little_endian的,则返回1
Jul 16 面试题
叙述DBMS对数据控制功能有哪些
Jun 12 面试题
请解释在new与override的区别
Oct 29 面试题
.NET初级开发工程师面试题(包括Javascript)
Aug 22 面试题
SQL注入攻击的种类有哪些
Dec 30 面试题
C#中有没有运算符重载?能否使用指针?
May 05 面试题
施惠特软件测试面试题以及笔试题
May 13 面试题
一套软件开发工程师笔试题
May 18 面试题
北京振戎融通Java面试题
Sep 03 面试题
Yahoo的PHP面试题
May 26 #面试题
PHP数据运算类型都有哪些
Nov 05 #面试题
一套PHP的笔试题
May 31 #面试题
新浪网技术部笔试题
Aug 26 #面试题
如何处理简单的PHP错误
Oct 14 #面试题
PHP面试题及答案二
May 23 #面试题
PHP经典面试题
Sep 03 #面试题
You might like
2021年最新CPU天梯图
2021/03/04 数码科技
php封装的连接Mysql类及用法分析
2015/12/10 PHP
PHP的Yii框架中过滤器相关的使用总结
2016/03/29 PHP
php 截取GBK文档某个位置开始的n个字符方法
2017/03/08 PHP
老生常谈PHP面向对象之标识映射
2017/06/21 PHP
PHP应用跨时区功能的实现方法
2019/03/21 PHP
laravel-admin 实现给grid的列添加行数序号的方法
2019/10/08 PHP
Javascript miscellanea -display data real time, using window.status
2007/01/09 Javascript
用Javascript实现锚点(Anchor)间平滑跳转
2009/09/08 Javascript
JavaScript异步编程:异步数据收集的具体方法
2013/08/19 Javascript
jquery遍历筛选数组的几种方法和遍历解析json对象
2013/12/13 Javascript
JS中attr和prop属性的区别以及优先选择示例介绍
2014/06/30 Javascript
详解vue-cli + webpack 多页面实例应用
2017/04/25 Javascript
详解node child_process模块学习笔记
2018/01/24 Javascript
Vue仿微信app页面跳转动画效果
2019/08/21 Javascript
layui表单验证select下拉框实现验证的方法
2019/09/05 Javascript
JavaScript React如何修改默认端口号方法详解
2020/07/28 Javascript
Python中动态创建类实例的方法
2017/03/24 Python
python调用API实现智能回复机器人
2018/04/10 Python
Python Requests模拟登录实现图书馆座位自动预约
2018/04/27 Python
python处理csv中的空值方法
2018/06/22 Python
CentOS 7下安装Python3.6 及遇到的问题小结
2018/11/08 Python
python查询MySQL将数据写入Excel
2020/10/29 Python
浅谈Python xlwings 读取Excel文件的正确姿势
2021/02/26 Python
阿迪达斯俄罗斯官方商城:adidas俄罗斯
2017/03/08 全球购物
类、抽象类、接口的差异
2016/06/13 面试题
读书心得体会
2013/12/28 职场文书
生日主持词
2014/03/20 职场文书
大二学生自我检讨书
2014/10/23 职场文书
2015年全国助残日活动方案
2015/05/04 职场文书
起诉意见书范文
2015/05/19 职场文书
运动会100米广播稿
2015/08/19 职场文书
2019开业庆典剪彩仪式主持词!
2019/07/22 职场文书
导游词之藏龙百瀑景区
2019/12/30 职场文书
正确的理解和使用Django信号(Signals)
2021/04/14 Python
MySQL 慢查询日志深入理解
2021/04/22 MySQL