设为首页 收藏本站
查看: 676|回复: 0

[经验分享] 20100318-PHP面试考试题总结

[复制链接]

尚未签到

发表于 2017-3-29 11:34:54 | 显示全部楼层 |阅读模式
  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

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-357011-1-1.html 上篇帖子: windows下安装PHP缓存Xcache 下篇帖子: PHP文件上传源码分析(RFC1867)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表