Learn PHP MCQs
Prepare PHP MCQs (Multiple choice Questions) for exam and job interviews.
What does the `$_FILES` superglobal in PHP store?
1) Uploaded file information
2) Server information
3) Form data
4) Client information
Answer : Option 1
What does the `__destruct()` method in a PHP class do?
1) It is called when an object is destroyed
2) It is used to delete a class
3) It constructs an object
4) It finalizes the object
Answer : Option 1
Which function is used to start output buffering in PHP?
1) ob_start()
2) output_start()
3) start_buffer()
4) buffer_start()
Answer : Option 1
What is the correct way to get the number of elements in a multi-dimensional array in PHP?
1) count($array, COUNT_RECURSIVE)
2) sizeof($array, COUNT_RECURSIVE)
3) array_count($array)
4) count($array)
Answer : Option 1
How do you check if a variable is an object in PHP?
1) is_object()
2) is_object_var()
3) check_object()
4) is_var_object()
Answer : Option 1
Which function is used to send an HTTP status code in PHP?
1) http_response_code()
2) send_http_code()
3) set_http_status()
4) header()
Answer : Option 1
How do you measure the time taken for a PHP script to execute?
1) microtime()
2) time()
3) start_timer()
4) exec_time()
Answer : Option 1
Which function is used to split a string into an array by a regular expression in PHP?
1) preg_split()
2) split()
3) explode()
4) preg_match_all()
Answer : Option 1
Which function would you use to convert special characters to HTML entities in PHP?
1) htmlentities()
2) htmlspecialchars()
3) strip_tags()
4) convert_html()
Answer : Option 1
How do you delete a cookie in PHP?
1) Set the cookie expiration time to a past time
2) Use delete_cookie()
3) Unset the cookie variable
4) Use remove_cookie()
Answer : Option 1