Html Forms Handling(Php ) Questions and Answers

Question 1. Which one of the following should not be used while sending passwords or other sensitive information?
  1.    GET
  2.    POST
  3.    REQUEST
  4.    NEXT
Explanation:-
Answer: Option A. -> GET
Because the data is visible to everyone.

Question 2. What will be the value of the variable $input in the following PHP code?
  1.    Swapna Lawrence you are really pretty!
  2.    Swapna Lawrence you are reallypretty!
  3.    Swapna Lawrence you are really pretty!
  4.    Swapna Lawrence you are reallypretty!
Explanation:-
Answer: Option D. -> Swapna Lawrence you are reallypretty!
Italic tags might be allowable, but table tags could potentially wreak havoc on a page.

Question 3. Which function is used to remove all HTML tags from a string passed to a form?
  1.    remove_tags()
  2.    strip_tags()
  3.    tags_strip()
  4.    tags_remove()
Explanation:-
Answer: Option B. -> strip_tags()

Question 4. To validate an e-mail address, which flag is to be passed to the function filter_var()?
  1.    FILTER_VALIDATE_EMAIL
  2.    FILTER_VALIDATE_MAIL
  3.    VALIDATE_EMAIL
  4.    VALIDATE_MAIL
Explanation:-
Answer: Option A. -> FILTER_VALIDATE_EMAIL

Question 5. How many validation filters like FILTER_VALIDATE_EMAIL are currently available?
  1.    5
  2.    6
  3.    7
  4.    8
Explanation:-
Answer: Option C. -> 7
There are seven validation filters. They are FILTER_VALIDATE_EMAIL, FILTER_VALIDATE_BOOLEAN, FILTER_VALIDATE_FLOAT, FILTER_VALIDATE_INT, FILTER_VALIDATE_IP, FILTER_VALIDATE_REGEXP, FILTER_VALIDATE_URL.

Question 6. If the directive session.cookie_lifetime is set to 3600, the cookie will live until.
  1.    3600 sec
  2.    3600 min
  3.    3600 hrs
  4.    the browser is restarted
Explanation:-
Answer: Option A. -> 3600 sec
The lifetime is specified in seconds, so if the cookie should live 1 hour, this directive should be set to 3600.

Question 7. Which one of the following function is used to start a session?
  1.    start_session()
  2.    session_start()
  3.    session_begin()
  4.    begin_session()
Explanation:-
Answer: Option B. -> session_start()

Question 8. What is the default number of seconds that cached session pages are made available before the new pages are created?
  1.    360
  2.    180
  3.    3600
  4.    1800
Explanation:-
Answer: Option B. -> 180
The directive which determines this is session.cache_expire.

Question 9. Neglecting to set which of the following cookie will result in the cookie’s domain being set to the host name of the server which generated it.
  1.    session.domain
  2.    session.path
  3.    session.cookie_path
  4.    session.cookie_domain
Explanation:-
Answer: Option D. -> session.cookie_domain
The directive session.cookie_domain determines the domain for which the cookie is valid.

Question 10. What is the default time(in seconds) for which session data is considered valid?
  1.    1800
  2.    3600
  3.    1440
  4.    1540
Explanation:-
Answer: Option C. -> 1440
The session.gc_maxlifetime directive determines this duration. It can be set to any required value.