Learn PHP MCQs

Prepare PHP MCQs (Multiple choice Questions) for exam and job interviews.

What does the `extract()` function do in PHP?

1) Imports variables from an array into the current symbol table

2) Exports variables to an array

3) Removes variables from an array

4) None of the above

Answer : Option 1

How do you get the directory name from a file path in PHP?

1) dirname()

2) get_dir()

3) dir()

4) extract_dir()

Answer : Option 1

What is the output of `echo floor(4.7);` in PHP?

1) 4

2) 5

3) 4.7

4) Error

Answer : Option 1

Which function is used to write data to a file in PHP?

1) fwrite()

2) file_write()

3) write()

4) write_file()

Answer : Option 1

How do you retrieve the length of a string in PHP?

1) strlen()

2) strlength()

3) length()

4) str_len()

Answer : Option 1

What is the output of `echo 10 . 5;` in PHP?

1) 105

2) 15

3) Error

4) 5

Answer : Option 1

Which function is used to sort an array in descending order in PHP?

1) rsort()

2) sort()

3) array_sort()

4) sort_desc()

Answer : Option 1

How do you get the type of a variable in PHP?

1) gettype()

2) var_type()

3) type()

4) variable_type()

Answer : Option 1

What is the output of `echo strtolower("HELLO");` in PHP?

1) hello

2) HELLO

3) Hello

4) Error

Answer : Option 1

Which function is used to shuffle the elements of an array in PHP?

1) shuffle()

2) array_shuffle()

3) randomize()

4) mix()

Answer : Option 1