每日一题(16)

上一篇 / 下一篇  2007-10-27 03:19:01 / 个人分类:每日一题

9. What happens when a form submitted to a PHP scrīpt contains two elements with the same name?

A. They are combined in an array and stored in the appropriate superglobal array

B. The value of the second element is added to the value of the first in the appropriate superglobal array

C. The value of the second element overwrites the value of the first in the appropriate superglobal array

D. The second element is automatically renamed

E. PHP outputs a warning

 

Answer:

PHP simply adds elements to the appropriate superglobal array as they are retrieved from the query string or POST information. As a result, if two elements have the same name, the first one will just be overwritten by the second. Therefore, Answer C is correct.

 

10. How would you store an array in a cookie?

A. By adding two square brackets ([]) to the name of the cookie

B. By using the implode function

C. It is not possible to store an array in a cookie due to storage limitations

D. By using the serialize function

E. By adding the keyword ARRAY to the name of the cookie

 

Answer:

Only Answer B is always correct. While the implode function can be used to convert an array into a string in a prerequisite of being able to store it in a cookie. it cannot guarantee that you will be able to reconstruct the array at a later date the way serialize() can. Storing an array in a cookie may not be a good idea because browsers only allow a limited amount of storage space for each cookie, but that's not always the case--you should be able to store relatively small arrays without much in the way of problems.

 


TAG: 每日一题

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

数据统计

  • 访问量: 16523
  • 日志数: 87
  • 建立时间: 2007-09-29
  • 更新时间: 2008-04-15

RSS订阅

Open Toolbar