热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

测试您的PHP水平的题目_php文摘

测试您的PHP水平的题目
在 Unix Review 上看到这个很有意思的测试,和大家共享。
UnixReview.com
May 2007
Test Your Knowledge of PHP
by Emmett Dulaney

From: http://www.unixreview.com/documents/s=10130/ur0705d/

Increasingly, PHP seems to be the tool/language that is used to make Web sites dynamic. While it is far from the only open source scripting language available, PHP's abilities and features are quickly making it not only a must-have in the Web world but also a topic on many certification exams. Following are fifty questions on PHP at the knowledge level found on beginning/intermediate certification exams. Good luck (answers are at the end of the article)!

1. What is the closing tag used by a PHP-driven web page?

A. />
B. #>
C. ?>
D. .>

2. Which PHP conditional operator means the values are equal AND of the same data type?

A. ==
B. ||
C. ===
D. ==?

3. Which of the following statements is true regarding variables in PHP (choose two)?

A. Variable names in PHP are case sensitive.
B. Variable names in PHP are not case sensitive.
C. PHP variables need to be declared before they can be used.
D. PHP variables do not need to be declared before they can be used.

4. You are evaluating a script written by a previous employee. That script contains a require statement that causes the script to exit when an error occurs. You want to change this so the script will generate a warning when such an error occurs, but keep on running. What should you replace require with?

A. involve
B. need
C. include
D. call_for

5. Which of the following does not represent a comment in a PHP script?

A. // This is a comment
B.
C. # This is a comment
D. /* This is a comment */

6. Which escape character in PHP renders a linefeed?

A. \n
B. \r
C. \t
D. \\

7. What file is used to configure global PHP settings? ______________ (Fill in the blank.)

8. If the value of $AU is currently 7, what is its value as a result of the command $AU++;

A. 8
B. 9
C. 14
D. 49

9. Which printf type specifier is used for a floating point value?

A. d
B. f
C. s
D. u

10. Which PHP logical operator is used to see if both a and b are true?

A. a & b
B. a && b
C. a | b
D. a || b

11. If an array holds 100 entries, which identifier signifies the first entry?

A. 100
B. 99
C. 1
D. 0

12. What function must be called to send the random number generator before array_rand()?

A. limit()
B. scope()
C. srand()
D. hinum()

13. Which two choices below represent the default order resulting from a sort utilizing asort()?

A. A-Z
B. Z-A
C. 0-9
D. 9-0

14. Which of the following is not true for variable names?

A. They can contain an underscore character
B. They can begin with a numeric character
C. They can begin with an alpha character
D. They can contain alphanumeric characters

15. What is the opening tag used on a PHP-driven web page?

A. B. C. D.


16. What are used to separate blocks of statements within a control structure?

A. brackets [ ]
B. parentheses ( )
C. curly braces { }
D. quotation marks ""

17. Which function can be used to assign a data type to a variable?

A. assign
B. assigntype
C. settype
D. type

18. Which HTTP variable contains the IP address of the machine making a request?

A. ADDR_IP
B. ADDR
C. IP_ADDR
D. REMOTE_ADDR

19. You are creating a simple form for web users to send you a message. Which method should be used with that form?

A. POST
B. GET
C. SEND
D. READ

20. Within your PHP script, you are performing a pision operation on two variables. What data type is assigned to the pision result, by default, if it is a fractional result?

A. integer
B. double
C. string
D. Boolean

21. Which mode of the fopen() function opens a file for reading or writing, maintains exiting content, and places the file pointer at the beginning of the file?

A. w
B. a
C. r+
D. w+

22. Which function can be used to copy a file?

A. copy()
B. clone()
C. rename()
D. repr()

23. Which of the following is used to set a COOKIE to expire 24 hours from now?

A. $COOKIE_expire = time() +24
B. $COOKIE_expire = time() +1440
C. $COOKIE_expire = time() +86400

24. Which character is used as a statement terminator to indicate the end of a PHP command?

A. =
B. #
C. |
D. ;

25. Which of the following commands will initialize the $days array?

A. $days = ()
B. $days = array();
C. $days = ""
D. $days = initialize [ ]
E. 12345
F. 12,3,45
G. 1{2,3,4}5

26. What function can be used to see if a file exists?

A. file()
B. file_there()
C. exist_file()
D. file_exists()

27. To create a COOKIE, your code uses the following entry: SetCOOKIE ("user", "Emmett Dulaney", time() +1800); Which of the following is the best to use to see the value "Emmett Dulaney"?

A. $user
B. $COOKIE[user]
C. $_COOKIE[user]
D. $COOKIE_user

28. Which of the following should be used to combine two or more existing arrays?

A. array_add()
B. array_merge()
C. array_join()
D. array_combine()

29. What function is used to determine whether a session has been started for the current user and then start one if necessary? __________ (Fill in the blank.)

30. After opening a file with the fopen() function, what is used to close the file pointer?

A. fclose()
B. close()
C. die()
D. end()

31. Which of the following functions can be used to show the data type for the $remain variable?

A. echo show($remain);
B. echo gettype($remain);
C. echo type($remain);
D. echo explain($remain);

32. Which of the following functions removes a directory from a file system?

A. rmdir()
B. dir()
C. del()
D. dir_gone()

33. What is the difference between sleep() and usleep()?

A. sleep() suspends operations and usleep() resumes them
B. sleep() accepts seconds and usleep() accepts milliseconds
C. sleep() works for the current process and usleep() works for all processes
D. sleep() can only be specified for the current user and usleep() can be specified for all users

34. You need to know how many elements are in an array. What function should you use to count this?

A. list()
B. count()
C. number()
D. sizeof()

35. Information about a session, by default, is configured in the PHP configuration file to be saved beneath which directory?

A. /var
B. /etc
C. /tmp
D. /usr

36. Which of the following contains variables provided to a script by means of the server environment?

A. $_FILES
B. $_POST
C. $_GET
D. $_ENV

37. Which of the following can be used to delete a file?

A. delete()
B. rid()
C. unlink()
D. close()

38. Which of the following functions can be used to destroy a variable?

A. erase
B. fi
C. remove
D. unset

39. Which mode of the fopen() function opens a file for writing and places the file pointer at the end of the file?

A. w
B. a
C. r+
D. w+

40. Which HTTP variable contains the browser type, and browser version, among other values?

A. BROWSE_AGENT
B. BROWSER_TYPE
C. BROWSER_ENV
D. HTTP_USER_AGENT

41. If the current value of $bsns is 4400, what is the new value as a result of this command: $bsns -= 150;

A. -150
B. 150
C. 4250
D. 4400
E. 4550
F. "4400-150"

42. What are used to enclose conditional expressions?

A. brackets [ ]
B. parentheses ( )
C. curly braces { }
D. quotation marks " "

43. Which PHP data type can be either TRUE or FALSE?

A. Truth
B. Integer
C. Boolean
D. Float

44. Which of the following contains variables provided to a script by means of file uploads?

A. $_FILES
B. $_POST
C. $_GET
D. $_ENV

45. Which constant identifies the highest random number that the system can generate?

A. URAND
B. END_NUMBER
C. ULIMIT
D. RAND_MAX

46. PHP provides support for POSIX through functions of which class?

A. grep
B. ereg
C. psx
D. efgrp

47. From a Boolean standpoint, every zero value in PHP is considered:

A. True
B. False
C. Error
D. Null

48. Which function places results in the opposite order of asort()?

A. arsort()
B. rev()
C. trosa()
D. zsort()

49. Which printf type specifier is used for a string?

A. d
B. f
C. s
D. u

50.Which PHP conditional operator means not equal to?

A. !=
B. =!
C. <=>
D. <>

Answers

1. The closing tag used by PHP is ?>. Answer: C.

2. The PHP conditional operator of three equal signs (===) means the values are equal and of the same data type. Answer: C.

3. PHP variable names are case sensitive and variables do not need to be declared before they can be used. Answer: A and D.

4. The include instruction will create a warning, but allow the script to continue running when an error is encountered. Answer: C.

5. There are at least three ways to create comments in a PHP script, and
6. The \n escape character in PHP renders a linefeed. Answer: A.

7. The global configuration file is php.ini.

8. The command $AU++; increments the variable by one – changing it from 7 to 8. Answer: A.

9. The printf type specifier f is used for a floating point value. Answer: B.

10. The PHP logical operator to use to see if both a and b are true would be a && b. Answer: B.

11. The first entry is 0, the second is 1, and the numbers increment from there. Answer: D.

12. The srand() function must be called to send the random number generator before array_rand(). Answer: C.

13. The default order resulting from a sort utilizing asort() is alphabetic (A-Z) and lowest to highest (0-9). Answer: A and C.

14. Variable names cannot begin with a numeric character. Answer: B.

15. The opening tag used by PHP is
16. Curly braces are used to separate blocks of statements within a control structure. Answer: C.

17. The settype function can be used to assign a data type to a variable. Answer: C.

18. The REMOTE_ADDR HTTP variable contains the IP address of the machine making a request. Answer: D.

19. The POST method should be used for a form as described. Answer: A.

20. If the result is not a whole number, it is assigned the double data type If it is a whole number, integer is assigned. Answer: B.

21. The r+ mode of the fopen() function opens a file for reading or writing, maintains exiting content, and places the file pointer at the beginning of the file. Answer: C.

22. The copy() function can be used to copy a file. Answer: A.

23. To set a COOKIE to expire 24 hours from now, compute the number of seconds and use the time() function: $COOKIE_expire = time() +86400. Answer: C.

24. The semicolon character (;) is used as a statement terminator to indicate the end of a PHP command. Answer: D.

25. The command $days = array(); will initialize the $days array. Answer: B.

26. The file_exists() function can be used to see if a file by the given name is already in existence. Answer: D.

27. The value of $_COOKIE[user] is equal to what was set in the COOKIE. Answer: C.

28. The array_merge() function should be used to combine two or more existing arrays. Answer: B.

29. The function to use is session_start()

30. After opening a file with the fopen() function, fclose() is used to close the file pointer. Answer: A.

31. The gettype function can be used to show the data type for a variable. Answer: B.

32. The rmdir() function removes a directory from a file system. Answer: A.

33. sleep() accepts seconds and usleep() accepts milliseconds. Answer: B.

34. The sizeof() function can tell how many elements are in an array Answer: D.

35. Information about a session, by default, is configured in the PHP configuration file to be saved beneath /tmp. Answer: C.

36. $_ENV contains variables provided to a script by means of the server environment. Answer: D.

37. The unlink() function can be used to delete a file. Answer: C.

38. The unset function can be used to destroy a variable. Answer: D.

39. The "a" mode of the fopen() function opens a file for writing and places the file pointer at the end of the file. Answer: B.

40. The HTTP_USER_AGENT HTTP variable contains the browser type, and browser version, among other values. Answer: D.

41. This operation subtracts 150 from the existing value. Answer: C.

42. Parentheses are used to enclose conditional expressions. Answer: B.

43. The Boolean PHP data type can be either TRUE or FALSE. Answer: C.

44. $_FILES contains variables provided to a script by means of file uploads. Answer: A.

45. The RAND_MAX constant identifies the highest random number that a system can generate. Answer: D.

46. PHP provides support for POSIX through functions of the ereg class. Answer: B.

47. From a Boolean standpoint, every zero value in PHP is considered false. Answer: B.

48. The arsort() function places results in the opposite order of asort(). Answer: A.

49. The printf type specifier s is used for a string. Answer: C.

50. The != PHP conditional operator means not equal to. Answer: A.

Emmett Dulaney is the author of the several books on Linux/Unix and certification as well as a columnist for UnixReview.com. Emmett's blog can be found at: http://edulaney.blogspot.com, and he can be reached (and welcomes your comments) at: edulaney@insightbb.com.

推荐阅读
  • php还能用多少年(php还行吗)
    导读:很多朋友问到关于php还能用多少年的相关问题,本文编程笔记就来为大家做个详细解答,供大家参考,希望对大家有所帮助!一起来看看吧!本文目录一览: ... [详细]
  • 1、概念解读1.1什么是链接?链接是一种在共享文件和访问它的用户的若干目录项之间建立联系的方法。Linux系统中有两种链接:硬链接(HardLink)和软链接(SoftLink), ... [详细]
  • PHP调试凶器Xdebug安装配置教程:PHP调试利器Xdebug安装配置教程作者:zhanhailiang日期:2013-03-111.简述引用官方描述:TheXdebugext ... [详细]
  • 在Docker中,将主机目录挂载到容器中作为volume使用时,常常会遇到文件权限问题。这是因为容器内外的UID不同所导致的。本文介绍了解决这个问题的方法,包括使用gosu和suexec工具以及在Dockerfile中配置volume的权限。通过这些方法,可以避免在使用Docker时出现无写权限的情况。 ... [详细]
  • 本文介绍了lua语言中闭包的特性及其在模式匹配、日期处理、编译和模块化等方面的应用。lua中的闭包是严格遵循词法定界的第一类值,函数可以作为变量自由传递,也可以作为参数传递给其他函数。这些特性使得lua语言具有极大的灵活性,为程序开发带来了便利。 ... [详细]
  • 学习SLAM的女生,很酷
    本文介绍了学习SLAM的女生的故事,她们选择SLAM作为研究方向,面临各种学习挑战,但坚持不懈,最终获得成功。文章鼓励未来想走科研道路的女生勇敢追求自己的梦想,同时提到了一位正在英国攻读硕士学位的女生与SLAM结缘的经历。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • 知识图谱——机器大脑中的知识库
    本文介绍了知识图谱在机器大脑中的应用,以及搜索引擎在知识图谱方面的发展。以谷歌知识图谱为例,说明了知识图谱的智能化特点。通过搜索引擎用户可以获取更加智能化的答案,如搜索关键词"Marie Curie",会得到居里夫人的详细信息以及与之相关的历史人物。知识图谱的出现引起了搜索引擎行业的变革,不仅美国的微软必应,中国的百度、搜狗等搜索引擎公司也纷纷推出了自己的知识图谱。 ... [详细]
  • MACElasticsearch安装步骤及验证方法
    本文介绍了MACElasticsearch的安装步骤,包括下载ZIP文件、解压到安装目录、启动服务,并提供了验证启动是否成功的方法。同时,还介绍了安装elasticsearch-head插件的方法,以便于进行查询操作。 ... [详细]
  • Oracle分析函数first_value()和last_value()的用法及原理
    本文介绍了Oracle分析函数first_value()和last_value()的用法和原理,以及在查询销售记录日期和部门中的应用。通过示例和解释,详细说明了first_value()和last_value()的功能和不同之处。同时,对于last_value()的结果出现不一样的情况进行了解释,并提供了理解last_value()默认统计范围的方法。该文对于使用Oracle分析函数的开发人员和数据库管理员具有参考价值。 ... [详细]
  • 单目标应用:最有价值球员算法(Most Valuable Player Algorithm,MVPA)求解旅行商问题TSP
    一、最有价值球员算法最有价值球员算法(MostValuablePlayerAlgorithm,MVPA)由Bouchekara等人于20 ... [详细]
  • 错误:requireluasql.mysqlstdin:1:moduleluasql.mysqlnotfound:nofieldpackage.preload[lua ... [详细]
  • nsitionalENhttp:www.w3.orgTRxhtml1DTDxhtml1-transitional.dtd ... [详细]
  • 爬虫框架Scrapy(三)
    正文共:2957字6图预计阅读时间:8分钟每日分享Bethetypeofpersonyouwanttomeet.努力变成理想的模样。小闫笔记࿱ ... [详细]
  • springcloud:微服务涉及哪些技术、有哪些核心组件(二)
    0.引言上一期我们介绍了什么是微服务,微服务的基础概念,那么本期我们来介绍一下微服务涉及的技术点以及所需要的组件1.微服务涉及哪些技术1.1、基础 ... [详细]
author-avatar
宝丫2502933885
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有