2015php面试题,PHP面试题附答案

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(): 本函数对数组的值进行排序,

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 程式网页的'一部份,PHP面试题附答案》(https://www.unjs.com)。常用的函式,亦可以这个方法将它引入网页中。错误产生致命错误。

include:这个函式一般是放在流程控制的处理区段中。PHP 程式网页在读到 include 的档案时,才将它读进来。这种方式,可以把程式执行时的流程简单化。错误产生警报。

include_once:此行为和include()语句类似,唯一区别是如果该文件中的代码已经被包含了,则不会再次包含。如同此语句名字暗示的那样,只会包含一次。

13. What function would you use to redirect the browser to a new page?

1. redir()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值