Learn PHP MCQs
Prepare PHP MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of `echo 2 ** 3;` in PHP?
1) 8
2) 6
3) 9
4) Error
Answer : Option 1
Which function is used to check if a file exists in PHP?
1) file_exists()
2) is_file()
3) check_file()
4) exists()
Answer : Option 1
What does the `array_map()` function do in PHP?
1) Applies a callback function to the elements of an array
2) Maps the keys of one array to another
3) Removes duplicate values from an array
4) None of the above
Answer : Option 1
How do you remove a directory in PHP?
1) rmdir()
2) remove_directory()
3) delete_dir()
4) remove_dir()
Answer : Option 1
What is the output of `echo "5" * 2;` in PHP?
1) 10
2) 52
3) Error
4) 5
Answer : Option 1
Which function is used to get the current script filename in PHP?
1) __FILE__
2) __DIR__
3) __SCRIPT__
4) __FILENAME__
Answer : Option 1
How do you check if a string contains a specific substring in PHP?
1) strpos()
2) strstr()
3) contains()
4) search()
Answer : Option 1
What is the output of `echo (int) "10 apples";` in PHP?
1) 10
2) 0
3) Error
4) None of the above
Answer : Option 1
Which function is used to get a random value from an array in PHP?
1) array_rand()
2) array_random()
3) rand()
4) array_pick()
Answer : Option 1
How do you find the minimum value in an array in PHP?
1) min()
2) array_min()
3) minimum()
4) get_min()
Answer : Option 1