带答案的PHP面试题 英文题目 中文回答

<p>1. Which of the following will not add john to the users array?<br /> 1. $users[] = &lsquo;john&rsquo;;<br /> 2. array_add($users,&rsquo;john&rsquo;);<br /> 3. array_push($users,&rsquo;john&rsquo;);<br /> 4. $users ||= &lsquo;john&rsquo;;<br /> Answer: 2,4<br /> 2. What&rsquo;s the difference between sort(), asort() and ksort(),rsort()? Under what circumstances would you use each of these?<br /> sort(): 本函数对数组的值进行排序。当本函数结束时数组单元将被从最低到最高重新安排,array 中的单元赋予新的键名。这将删除原有的键名而不仅是重新排序。<br /> asort(): 这个函数将数组的值重新排序,由小至大排列。数组的索引亦跟着值的 顺序而变动。当您在程序中需要重新整理数组值的 顺序时,就可以使用这个函数。<br /> ksort(): 对数组按照键名排序,保留键名到数据的关联。本函数主要用于关联数组。<br /> rsort(): 本函数对数组进行逆向排序(最高到最低)。与sort()执行相反的操作。<br /> 3. What would the following code print to the browser? Why?<br /> $num = 10;<br /> function multiply(){<br /> $num = $num * 10;<br /> }<br /> multiply();<br /> echo $num;<br /> 10<br /> 4. What is the difference between a reference and a regular variable? How do you pass by reference &amp; why would you want to?<br /> pass by reference like this functions(&amp;$vars);<br /> it likes more fast;<br /> 5. What functions can you use to add library code to the currently running script?<br /> inlcude() or require();<br /> 6. What is the difference between foo() &amp; @foo()?<br /> if foo() throw a error, will be alert, but @foo() no;<br /> 7. How do you debug a PHP application?<br /> xdebug or use die() do it;<br /> 8. What does === do? What&rsquo;s an example of something that will give true for &lsquo;==&rsquo;, but not &lsquo;===&rsquo;?<br /> === 用于精确比较 ex: (&rdquo; == null) =&gt; true but ( &rdquo;===null) =&gt;false;<br /> 9. How would you declare a class named &ldquo;myclass&rdquo; with no methods or properties?<br /> class myclass{<br /> }<br /> 10. How would you create an object, which is an instance of &ldquo;myclass&rdquo;?<br /> $myoject = new myclass();<br /> 11. How do you access and set properties of a class from within the class?<br /> getVar() or setVar() ;<br /> 12. What is the difference between include &amp; include_once? include &amp; require?<br /> require:PHP 程式在执行前,就会先读入 require 所指定引入的档案,使它变成 PHP 程式网页的一部份。常用的函式,亦可以这个方法将它引入网页中。错误产生致命错误。<br /> include:这个函式一般是放在流程控制的处理区段中。PHP 程式网页在读到 include 的档案时,才将它读进来。这种方式,可以把程式执行时的流程简单化。错误产生警报。<br /> include_once:此行为和include()语句类似,唯一区别是如果该文件中的代码已经被包含了,则不会再次包含。如同此语句名字暗示的那样,只会包含一次。<br /> 13. What function would you use to redirect the browser to a new page?<br /> 1. redir()<br /> 2. header()<br /> 3. location()<br /> 4. redirect()<br /> 2<br /> 14. What function can you use to open a file for reading and writing?<br /> 1. fget();<br /> 2. file_open();<br /> 3. fopen();<br /> 4. open_file();<br /> 3<br /> 15. What&rsquo;s the difference between mysql_fetch_row() and mysql_fetch_array()?<br /> mysql_fetch_row():返回根据所取得的行生成的数组,如果没有更多行则返回 FALSE。<br /> mysql_fetch_array(): 是mysq_fetch_row()的扩展版本。除了将数据以数字索引方式储存在数组中之外,还可以将数据作为关联索引储存,用字段名作为键名。<br /> 16. What does the following code do? Explain what&rsquo;s going on there.<br /> $date=&rsquo;08/26/2003&prime;;<br /> print ereg_replace(&rsquo;([0-9]+)/([0-9]+)/([0-9]+)&rsquo;,'2/1/3&prime;,$date);<br /> 本函数以 正则 的规则来解析比对字符串 ,欲取而代之的字符串为&rsquo;2/1/3&prime;。<br /> 返回值为字符串类型,为取代后的字符串结果。<br /> 17. Given a line of text $string, how would you write a regular expression to strip all the HTML tags from it?<br /> strip_tags<br /> 18. What&rsquo;s the difference between the way PHP and Perl distinguish between arrays and hashes?<br /> 19. How can you get round the stateless nature of HTTP using PHP?<br /> 20. What does the GD library do?<br /> 21. Name a few ways to output (print) a block of HTML code in PHP?<br /> 22. Is PHP better than Perl? ? Discuss.<br /> 如果成功则返回 TRUE,失败则返回 FALSE。</p>
RangeTime:0.008871s
RangeMem:211.61 KB
返回顶部 留言