欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

据说是雅虎的一份PHP面试题附答案

程序员文章站 2023-04-07 17:32:46
从网上搜集到的,据说是雅虎的面试题。 1. which of the following will not add john to the users array? 1....
从网上搜集到的,据说是雅虎的面试题。
1. which of the following will not add john to the users array?
1. $users[] = 'john';
2. array_add($users,'john'); //wrong
3. array_push($users,'john');
4. $users ||= 'john'; //wrong
2. what's the difference between sort(), asort() and ksort? under what circumstances would you use each of these?
my an:sort()-排序 asort()-保持key值排序 ksort()-以key顺序排序 rsort()-逆排序 arsort()-保持key值逆排序 krsort()-以key逆顺序排序
3. what would the following code print to the browser? why?
$num = 10;
function multiply()
{
$num = $num * 10;
}
multiply();
echo $num;
my an:10 because var scope4. what is the difference between a reference and a regular variable? how do you pass by reference & why would you want to?
5. what functions can you use to add library code to the currently running script?
6. what is the difference between foo() & @foo()?
7. how do you debug a php application?
8. what does === do? what's an example of something that will give true for ‘==', but not ‘==='?
9. how would you declare a class named “myclass” with no methods or properties?
10. how would you create an object, which is an instance of “myclass”?
11. how do you access and set properties of a class from within the class?
12. what is the difference between include & include_once? include & require?
13. what function would you use to redirect the browser to a new page?
1. redir() 2. header() 3. location() 4. redirect()
my an :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();my an :315. what's the difference between mysql_fetch_row() and mysql_fetch_array()?
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);17. given a line of text $string, how would you write a regular expression to strip all the html tags from it?
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.