Learn PHP MCQs
Prepare PHP MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of `echo null ?? "default";` in PHP?
1) default
2) null
3) Error
4) None of the above
Answer : Option 1
Which function is used to retrieve the current Unix timestamp in PHP?
1) time()
2) timestamp()
3) current_time()
4) now()
Answer : Option 1
How do you get the file extension of a given filename in PHP?
1) pathinfo()
2) get_extension()
3) file_extension()
4) ext()
Answer : Option 1
What does the `htmlentities()` function do in PHP?
1) Converts special characters to HTML entities
2) Converts HTML entities to their corresponding characters
3) Removes HTML tags from a string
4) Escapes special characters in a string
Answer : Option 1
Which function is used to send raw HTTP headers in PHP?
1) header()
2) send_header()
3) http_header()
4) raw_header()
Answer : Option 1
How do you convert a JSON string to a PHP array in PHP?
1) json_decode()
2) json_encode()
3) json_convert()
4) json_parse()
Answer : Option 1
What does the `strtoupper()` function do in PHP?
1) Converts a string to uppercase
2) Converts a string to lowercase
3) Capitalizes the first letter of each word in a string
4) Capitalizes the first letter of a string
Answer : Option 1
Which function is used to send a raw HTTP POST request in PHP?
1) file_get_contents()
2) curl_post()
3) http_post()
4) send_post()
Answer : Option 1
How do you find the number of occurrences of a substring in a string in PHP?
1) substr_count()
2) str_count()
3) count_substr()
4) str_repeat()
Answer : Option 1
What does the `fgetcsv()` function do in PHP?
1) Parses a line from an open file and returns an array of fields
2) Reads an entire CSV file into an array
3) Writes an array to a CSV file
4) None of the above
Answer : Option 1