Chinaunix首页 | 论坛 | 博客
  • 博客访问: 92199
  • 博文数量: 33
  • 博客积分: 1465
  • 博客等级: 上尉
  • 技术积分: 345
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-31 13:51
文章分类

全部博文(33)

文章存档

2011年(2)

2010年(31)

我的朋友

分类: LINUX

2010-11-07 10:54:17


答案在这里是自己写的,但是不排除参考网上的啊。。。嘎嘎。。

1. Which of the following will not add john to the users array?

  1. 1. $users[] = 'john'
  2. 2. array_add($users,'john'); 
  3. 3. array_push($users,'john'); 
  4. 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 '==='?

===既要值相等,也要类型相同。

例子也很简单

  1. var_dump('a' == 0); //bool(true)  
  2. var_dump('a' === 0); //bool(false)   



9. How would you declare a class named “myclass” with no methods or properties?

  1. class myclass{} 



10. How would you create an object, which is an instance of “myclass”?

  1. $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?

哈哈,手册上有啊。

  1. function theRealStripTags($string)  
  2. {  
  3.    //while there are tags left to remove  
  4.    while(strstr($string'>'))  
  5.    {  
  6.        //find position of first carrot  
  7.        $currentBeg = strpos($string'<');  
  8.          
  9.        //find position of end carrot  
  10.        $currentEnd = strpos($string'>');  
  11.          
  12.        //find out if there is string before first carrot  
  13.        //if so save it in $tmpstring  
  14.        $tmpStringBeg = @substr($string, 0, $currentBeg);  
  15.          
  16.        //find out if there is string after last carrot  
  17.        //if so save it in $tmpStringEnd  
  18.        $tmpStringEnd = @substr($string$currentEnd + 1, strlen($string));  
  19.          
  20.        //cut the tag from the string  
  21.        $string = $tmpStringBeg.$tmpStringEnd;  
  22.    }  
  23.          
  24.    return $string;  
  25. }  
  26.  
  27. //Returns "test"  
  28. 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.
 

先提交,答案待续

阅读(781) | 评论(1) | 转发(0) |
0

上一篇:linux下SVN配置

下一篇:某公司的PHP笔试题

给主人留下些什么吧!~~

chinaunix网友2010-11-08 15:32:14

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com