Learn PHP MCQs
Prepare PHP MCQs (Multiple choice Questions) for exam and job interviews.
How can you increase the execution time of a PHP script?
1) set_time_limit()
2) increase_time()
3) set_execution_time()
4) execution_time()
Answer : Option 1
Which of the following function is used to sort an array by key in PHP?
1) ksort()
2) key_sort()
3) array_ksort()
4) key_array_sort()
Answer : Option 1
Which of the following function is used to strip whitespace from the beginning and end of a string?
1) trim()
2) ltrim()
3) rtrim()
4) strip()
Answer : Option 1
How do you convert a string to lowercase in PHP?
1) strlower()
2) tolower()
3) strtolower()
4) lower()
Answer : Option 3
What is the correct way to redirect a user in PHP?
1) redirect()
2) header("Location: url");
3) location("url");
4) go_to("url");
Answer : Option 2
Which function is used to find the first occurrence of a string inside another string?
1) strpos()
2) strstr()
3) findstr()
4) strchr()
Answer : Option 1
Which of the following is used to destroy a session in PHP?
1) session_destroy()
2) destroy_session()
3) end_session()
4) session_end()
Answer : Option 1
Which of the following function is used to create a cookie in PHP?
1) setcookie()
2) createcookie()
3) makecookie()
4) cookie()
Answer : Option 1
What is the correct way to count the number of elements in an array?
1) array_count()
2) count()
3) sizeof()
4) array_size()
Answer : Option 2
How do you remove the last element from an array in PHP?
1) array_pop()
2) array_remove()
3) array_delete()
4) pop()
Answer : Option 1