Learn PHP MCQs
Prepare PHP MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is used to calculate the absolute value of a number in PHP?
1) abs()
2) absolute()
3) getabs()
4) calc_abs()
Answer : Option 1
Which of the following is used to generate a string with a specific character repeated in PHP?
1) str_repeat()
2) repeat()
3) str_repeat_char()
4) str_repeat_str()
Answer : Option 1
How do you generate a secure hash of a string in PHP?
1) password_hash()
2) hash_string()
3) str_hash()
4) secure_hash()
Answer : Option 1
Which of the following is used to create a JSON string from an array in PHP?
1) json_encode()
2) encode_json()
3) json_array()
4) arr_to_json()
Answer : Option 1
How do you pause the execution of a script for a specific number of seconds in PHP?
1) sleep()
2) pause()
3) wait()
4) delay()
Answer : Option 1
Which of the following is used to check if a value is numeric in PHP?
1) is_numeric()
2) numeric()
3) check_numeric()
4) isnumber()
Answer : Option 1
How do you send an email using PHP?
1) mail()
2) sendmail()
3) email()
4) postmail()
Answer : Option 1
Which of the following is used to redirect to another page in PHP?
1) header()
2) redirect()
3) goto()
4) location()
Answer : Option 1
What does the `include` statement do in PHP?
1) Includes a file multiple times
2) Includes a file once
3) Includes a file and generates a warning if it fails
4) Includes a file and stops execution if it fails
Answer : Option 3
Which of the following is true about PHP variables?
1) They must start with a letter or underscore
2) They must start with a dollar sign ($)
3) They can contain letters, numbers, and underscores
4) All of the above
Answer : Option 4