Q. What is the use of PHP $_SERVER variable?

  • (A) To update the content on the server
  • (B) To access the information about headers, paths, and script locations
  • (C) To access and update the database records on the server
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the above

Q. Which element of the of PHP $_SERVER variable is used to get the path of the current script?

  • (A) SCRIPT_NAME
  • (B) SCRIPT_PATH
  • (C) PATH
  • (D) FILE_PATH
πŸ’¬ Discuss
βœ… Correct Answer: (A) SCRIPT_NAME

Q. Which element of the of PHP $_SERVER variable is used to get the filename of the currently executing script?

  • (A) PATH
  • (B) FILE_PATH
  • (C) PHP_SELF
  • (D) SELF
πŸ’¬ Discuss
βœ… Correct Answer: (C) PHP_SELF

Q. Which PHP global variable is used to collect data after submitting an HTML form?

  • (A) $_GET
  • (B) $_REQUEST
  • (C) $_POST
  • (D) $_ENV
πŸ’¬ Discuss
βœ… Correct Answer: (B) $_REQUEST

Q. Which PHP global variable is used to collect form data after submitting an HTML form with method="post"?

  • (A) $_GET
  • (B) $_REQUEST
  • (C) $_POST
  • (D) $_ENV
πŸ’¬ Discuss
βœ… Correct Answer: (C) $_POST

Q. What is the return value of preg_match() function?

  • (A) 0 or 1
  • (B) False or True
  • (C) 0, less than 1, or greater then 1
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (A) 0 or 1

Q. What will be the output of the following PHP code?

Code:
<?php
$str = "Hello, IncludeHelp";
$pattern = "/includehelp/i";

echo preg_match($pattern, $str); 
?>
  • (A) 0
  • (B) 1
  • (C) 5
  • (D) 7
πŸ’¬ Discuss
βœ… Correct Answer: (A) 0

Q. What will be the output of the following PHP code?

Code:
<?php
$str = "Hello, IncludeHelp";
$pattern = "/el/m";

echo preg_match($pattern, $str); 
?>
  • (A) 0
  • (B) 1
  • (C) 5
  • (D) 7
πŸ’¬ Discuss
βœ… Correct Answer: (B) 1

Q. What are the metacharacters in PHP Regular Expression?

  • (A) Metacharacters are characters with a special meaning
  • (B) Metacharacters are set of symbols to perform the mathematical operations on the characters
  • (C) Metacharacters are characters written within the double quotes to search in the string
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (A) Metacharacters are characters with a special meaning

Q. What is the search pattern to find any character from the range 5 to 8?

  • (A) [5 to 8]
  • (B) [5...8]
  • (C) [5-8]
  • (D) [4-9]
πŸ’¬ Discuss
βœ… Correct Answer: (C) [5-8]