分类: LINUX
2010-11-07 10:54:17
答案在这里是自己写的,但是不排除参考网上的啊。。。嘎嘎。。
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';
2.没有array_add这个函数; 4.语法错误。
2. What's the difference between sort(), asort() and ksort? Under what circumstances would you use each of these?
看手册的:
sort:本函数对数组进行排序。当本函数结束时数组单元将被从最低到最高重新安排。注: 本函数为 array 中的单元赋予新的键名。这将删除原有的键名而不仅是重新排序。
asort:对数组进行排序并保持索引关系
ksort:对数组按照键名排序,保留键名到数据的关联。
3. What would the following code print to the browser? Why?
$num = 10;
function multiply(){
$num = $num * 10;
}
multiply();
echo $num;
10,一个是全局变量,一个是局部变量。而且PHP中的全局变量跟C中的不一样,在函数中使用要申请为全局变量才行。
4. 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?
require, include, require_once, include_once,com_load,dotnet_load(后两个是看答案的,-_-)
6. What is the difference between foo() & @foo()?
@是PHP中的错误控制运算符,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 '==='?
===既要值相等,也要类型相同。
例子也很简单
- var_dump('a' == 0); //bool(true)
- var_dump('a' === 0); //bool(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”?
- $myclass = new myclass();
11. How do you access and set properties of a class from within the class?
$this
12. What is the difference between include & include_once? include & require?
1.include_once只包含一次。
2.include产生警告,require导致一个致命错误。
13. What function would you use to redirect the browser to a new page?
1. redir()
2. header()
3. location()
4. redirect()
14. What function can you use to open a file for reading and writing?
1. fget();
2. file_open();
3. fopen();
4. open_file();
15. What's the difference between mysql_fetch_row() and mysql_fetch_array()?
mysql_fetch_row()返回一个数字索引的数组
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);
正则,把日跟月调换。结果是26/08/2003.
17. Given a line of text $string, how would you write a regular expression to strip all the HTML tags from it?
哈哈,手册上有啊。
- function theRealStripTags($string)
- {
- //while there are tags left to remove
- while(strstr($string, '>'))
- {
- //find position of first carrot
- $currentBeg = strpos($string, '<');
- //find position of end carrot
- $currentEnd = strpos($string, '>');
- //find out if there is string before first carrot
- //if so save it in $tmpstring
- $tmpStringBeg = @substr($string, 0, $currentBeg);
- //find out if there is string after last carrot
- //if so save it in $tmpStringEnd
- $tmpStringEnd = @substr($string, $currentEnd + 1, strlen($string));
- //cut the tag from the string
- $string = $tmpStringBeg.$tmpStringEnd;
- }
- return $string;
- }
- //Returns "test"
- echo theRealStripTags('
test ');
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.
先提交,答案待续
chinaunix网友2010-11-08 15:32:14
很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com