Learn PHP MCQs
Prepare PHP MCQs (Multiple choice Questions) for exam and job interviews.
How do you generate a unique session ID in PHP?
1) session_id()
2) session_start()
3) generate_session_id()
4) create_session_id()
Answer : Option 1
How do you format a date in PHP?
1) date()
2) format_date()
3) set_date()
4) date_format()
Answer : Option 1
How do you get the current date and time in PHP?
1) date()
2) time()
3) getdate()
4) datetime()
Answer : Option 1
How do you set a cookie in PHP?
1) setcookie()
2) create_cookie()
3) make_cookie()
4) cookie()
Answer : Option 1
Which function is used to return the length of a string in PHP?
1) strlen()
2) length()
3) count()
4) size()
Answer : Option 1
Which function is used to get the last modified time of a file in PHP?
1) filemtime()
2) filemodified()
3) lastmodified()
4) file_lastmodified()
Answer : Option 1
Which function is used to create an array containing a range of elements in PHP?
1) range()
2) array_fill()
3) array()
4) create_range()
Answer : Option 1
Which function is used to count the number of elements in an array in PHP?
1) count()
2) sizeof()
3) length()
4) Both A and B
Answer : Option 4
How do you convert a string to an integer in PHP?
1) intval()
2) convert_to_int()
3) to_int()
4) parseInt()
Answer : Option 1
Which function is used to split a string by a delimiter in PHP?
1) explode()
2) split()
3) str_split()
4) break()
Answer : Option 1