Learn PHP MCQs

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

What is the output of `echo strtoupper("hello");` in PHP?

1) HELLO

2) hello

3) Hello

4) Error

Answer : Option 1

How do you get the value of a specific query parameter in PHP?

1) Using `$_GET["param_name"]`

2) Using `query_param()`

3) Using `get_param()`

4) Using `param_value()`

Answer : Option 1

Which function is used to delete a session variable in PHP?

1) unset($_SESSION["variable_name"])

2) session_remove()

3) delete_session()

4) remove_variable()

Answer : Option 1

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

1) Reverses the order of elements in an array

2) Sorts an array in reverse order

3) Removes the last element of an array

4) None of the above

Answer : Option 1

How do you validate an integer value in PHP?

1) Using `filter_var()` with `FILTER_VALIDATE_INT`

2) Using `is_integer()`

3) Using `validate_int()`

4) Using `int_check()`

Answer : Option 1

What is the output of `echo 0.1 + 0.2 == 0.3;` in PHP?

1) false

2) true

3) Error

4) 0

Answer : Option 1

How do you handle errors in PHP?

1) Using try-catch blocks

2) Using error handling functions

3) Using `error_log()`

4) All of the above

Answer : Option 4

What is the purpose of the `mysqli_stmt_bind_param()` function?

1) Binds variables to a prepared statement

2) Executes a prepared statement

3) Fetches results from a prepared statement

4) Prepares a statement for execution

Answer : Option 1