Learn PHP MCQs
Prepare PHP MCQs (Multiple choice Questions) for exam and job interviews.
What does the `count_chars()` function do in PHP?
1) Returns information about the characters used in a string
2) Counts the number of characters in a string
3) Counts the occurrences of each character in a string
4) None of the above
Answer : Option 1
How do you get the current line number in a PHP script?
1) __LINE__
2) __ROW__
3) __POS__
4) __LINENO__
Answer : Option 1
Which function is used to convert a string to an array in PHP?
1) explode()
2) split()
3) str_split()
4) array()
Answer : Option 1
How do you replace a portion of a string in PHP?
1) substr_replace()
2) str_replace()
3) replace()
4) string_replace()
Answer : Option 1
What is the output of `echo "PHP" == "php";` in PHP?
1) false
2) true
3) Error
4) None of the above
Answer : Option 1
Which function is used to delete a file in PHP?
1) unlink()
2) delete()
3) remove()
4) file_delete()
Answer : Option 1
How do you convert a string to lowercase in PHP?
1) strtolower()
2) to_lower()
3) strlower()
4) lower()
Answer : Option 1
What does the `array_combine()` function do in PHP?
1) Creates an array by using one array for keys and another for its values
2) Combines two or more arrays into one
3) Merges the values of two arrays
4) None of the above
Answer : Option 1
Which function is used to replace occurrences of a substring in a string in PHP?
1) str_replace()
2) replace()
3) substr_replace()
4) replace_string()
Answer : Option 1
What is the output of `echo ceil(3.3);` in PHP?
1) 4
2) 3
3) 3.3
4) Error
Answer : Option 1