2010年3月18日面试考试题目及个人总结/*************by garcon1986*********************/1. Array_shift删除数组的第一个元素array_shift — Shift an element off the beginning of array<?php$stack = array ( "orange" , "banana" , "apple" , "raspberry" );$fruit = array_shift( $stack );print_r( $stack );?>结果 :Array([0] => banana[1] => apple[2] => raspberry)2. pcntl_exec(), exec()区别exec — Execute an external program<?php// outputs the username that owns the running php/httpd process// (on a system with the "whoami" executable in the path)echo exec( 'whoami' );?>结果 :garcon1986-pc/garcon1986函数对比:pcntl_exec — Executes specified program in current process spacesystem — Execute an external program and display the outputpassthru — Execute an external program and display raw output 3. If the input of chr() is $a and the output is $b, what function would take input $b and produce output $a?chr — Return a specific characterchr()函数的作用是:返回指定 ASCII值所对应的字符。<?phpecho chr( 52 ). "<br />" ;echo chr( 052 ). "<br />" ;echo chr( 0x52 ). "<br />" ;?>结果 :4*R相反功能的函数ord():Ord() - Return ASCII value of character返回字符对应的 ASCII 码<?php$str = "/n" ;echo ord( $str ). '<br />' ;$str2 = " " ;echo ord( $str2 );?>结果:1032printf — Output a formatted string 输出一个格式化的字符串<?phpprintf( 'http://www.%1$s.%2$s' , 'dayanmei' , 'com' );?>结果: http://www.dayanmei.comsprintf — Return a formatted string 返回一个格式化的字符串(不输出)<?php$s = sprintf( 'http://%3$s.%1$s.%2$s' , 'dayanmei' , 'com' , 'www' );echo $s ;?>结果: http://www.dayanmei.com4. magic quotesWhich function returns true when magic quotes are turned on?Warning: This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged.5. If $arr was an array of ten string elements with specific keys, what would array_values(ksort($arr)) do?Choose only one of the followingCreate a new array of just the values, then sort by the keysCreate a new array of just the values, then ignore the sort as there are no keysSort the array by key, then return a new array with just the valuesTrigger a warningNone of the aboveNo answer答案: Trigger a warningksort() 函数按照键名对数组排序,为数组值保留原来的键。<?php$my_array = array ( "c" => "Dog" , "b" => "Cat" , "a" => "Horse" );ksort($my_array );print_r( $my_array );?>结果 :Array ( [a] => Horse => Cat [c] => Dog )<?php$arr = array ( "b" => "world" , "a" => "hello" , "c" => "!" );ksort( $arr );print_r(array_values( $arr ));?>结果: Array ( [0] => hello [1] => world [2] => ! )<?php$arr = array ( "b" => "world" , "a" => "hello" , "c" => "!" );print_r(array_values(ksort( $arr )));?>结果: Warning : array_values() [function.array-values ]: The argument should be an array in C:/wamp/www/eclipse/ubb/test2.php on line 36. Output buffering compression is...Choose only one of the followingHigh on CPU resources, low on network resourcesLow on CPU resources, high on network resourcesHigh on CPU resources, high on network resourcesLow on CPU resources, low on network resourcesNo answer答案:目前不清楚7. Examine this code - on which line is there an error?<?phpclass dog {public function bark() {echo "Woof!"; }};$foo = new dog;$foo->bark();?>Choose only one of the followingLine 2 (class dog)Line 3 (public function bark())Line 4 (echo "Woof!")Line 6 ( }; )Line 8 ($foo = new dog)Line 9 ($foo->;bark())There is no errorNo answer答案: There is no error结果:Woof!8. What directive would you change in your php.ini file to disable assert()?Choose only one of the followingassertassert.activeassert.enableassert.assertassert.optionsNone of the aboveNo answer答案:assert.activephp.ini中assertion部分代码:[Assertion]; Assert(expr); active by default.; http://php.net/assert.active;assert.active = On; Issue a PHP warning for each failed assertion.; http://php.net/assert.warning;assert.warning = On; Don't bail out by default.; http://php.net/assert.bail;assert.bail = Off; User-function to be called if an assertion fails.; http://php.net/assert.callback;assert.callback = 0; Eval the expression with current error_reporting(). Set to true if you want; error_reporting(0) around the eval().; http://php.net/assert.quiet-eval;assert.quiet_eval = 09. "10" == 10: true or false?Choose only one of the followingTrueFalse答案: True<?phpif ( "10" == 10 ){echo "true" ;} else {echo "false" ;}?>结果 : true10. 010 >= 10: true or false?Choose only one of the followingTrueFalseNo answer答案: False<?phpif ( 010 < 10 ){echo "true" ;} else {echo "false" ;}?>结果 : true11. This SQL statement is valid "SELECT ID, Name FROM some_table ORDER BY Name WHERE ID < 100" - true or false?Choose only one of the followingTrueFalseNo answer答案: False例子 1:SELECT *FROM entrepriseWHERE name LIKE 'enterprise%'ORDER BY id结果显示正常。 Showing rows 0 - 1 (2 total, Query took 0.0004 sec)例子 2:SELECT *FROM entrepriseORDER BY idWHERE name LIKE 'enterprise%'错误:#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE name LIKE 'enterprise%' LIMIT 0, 30' at line 412. SQLite is compiled into PHP 5 by default: true or false?Choose only one of the followingTrueFalseNo answer答案:False(目前不太确定)13. What is the best description of a normalized table?Choose only one of the followingOne where optimal data types are usedOne where data is not repeatedOne where the schema is validOne that is properly indexedOne that has been defragmentedNo answer答案: One where optimal data types are used14. What is the case-insensitive version of the strcmp() function?Choose only one of the followingstrcmpi()stricmp()strcasecmp()istrcmp()No answer答案: strcasecmp()<?php//strcasecmp 注释:该函数是二进制安全的,且对大小写不敏感。比较两个字符串。// 该函数返回:// * 0 - 如果两个字符串相等// * <0 - 如果 string1 小于 string2// * >0 - 如果 string1 大于 string2echo strcasecmp( "Hello world!" , "HELLO WORLD!" ). "<br />" ; // 结果 0echo strcasecmp( "he" , "hf" ); // 结果 -1echo strcasecmp( "he" , "hd" ); // 结果 1?> 15. The parse_str() function...Choose only one of the followingChecks a string of PHP code is validChecks a string of PHP code is valid, then executes itSearches a string for non-English charactersConverts the contents of a string into variablesNo answer答案:Converts the contents of a string into variables16. What would implode(".", explode(",", $string)) do?Choose only one of the followingReplace all full stops (periods) with spacesReplace all full stops with commasDelete all full stopsNone of the aboveNo answer答案: No answer应该是把所有逗号 comma(,)替换为点号 stop(.)<?php$str = "Hello,world,It's,a,beautiful,day" ;//print_r (explode(",",$str));echo implode( "." , explode( "," , $str ));?>结果:Hello.world.It's.a.beautiful.day