What is PHP?
A) Server-side language
B) Markup language
C) Object-oriented language \
What does a PHP variable start with?
A) $
B) @
C) &
Which character is used to concatenate strings in PHP?
A) +
B) .
C) :
What is the correct way to declare a constant in PHP?
A) define(name,value)
B) constant(name,value)
C) const(name,value)
Which of the following is a valid PHP comment?
A) /* comment */
B) # comment #
C) // comment
What is the difference between == and === in PHP?
A) No difference
B) Type comparison
C) Value comparison
What is the purpose of the global keyword in PHP?
A) To access a variable outside of a function \
network error
a variable inside a function
C) To define a constant
Which of the following is NOT a valid PHP data type?
A) boolean
B) string
C) int32
What is the output of the following PHP code?
$a = 1;
echo ++$a + $a++;
A) 4
B) 3
C) 5
Which of the following is the correct way to include a file in PHP?
A) include 'file.php';
B) require 'file.php';
C) both A and B
What is the difference between include and require in PHP?
A) No difference
B) include will not stop the script if the file is not found
C) require will not stop the script if the file is not found \
What is the purpose of the die() function in PHP?
A) To end the script
B) To display an error message and end the script
C) To display a message and continue the script
What is the output of the following PHP code?
echo 1 . 2;
A) 3
B) 12
C) 21
What is the output of the following PHP code?
echo "1" + "2";
A) 3
B) 12
C) 21
What is the output of the following PHP code?
echo "1" . "2";
A) 3
B) 12
C) 21
What is the correct way to end a PHP statement?
A) ;
B) :
C) ,
What is the purpose of the continue statement in PHP?
A) To stop the script
B) To skip the rest of the current loop iteration
C) To jump to a specific point in the script
What is the purpose of the break statement in PHP?
A) To stop the script
B) To skip the rest of the current loop iteration
C) To exit the current loop
What is the output of the following PHP code?
$a = 5;
$b = &$a;
$b = 10;
echo $a;
A) 5
B) 10
C) Error
What is the output of the following PHP code?
echo "1" . 2 + 3; \
A) 15
B) 6
C) Error
What is a PHP data type?
A. Integer
B. Float
C. String
D. Boolean
Which of the following is not a valid PHP variable name?
A. $my_var
B. $_myVar
C. $myVar1
D. $1myVar
Which function is used to check if a variable is an array or not?
A. is_int()
B. is_string()
C. is_array()
D. is_bool()
What is the output of the following code snippet? $a = "hello"; \
echo $hello;
A. world
B. hello
C. Error
D. Null
5. Which PHP loop iterates over the values of an array?
A. while
B. for
C. foreach
D. do-while
6. What is the difference between ++$a and $a++?
A. Same output
B. $a++ is faster
C. ++$a increments first
D. ++$a is faster \
- What is the correct way to declare a constant in PHP?
A. define() \
What is the output of the following code snippet?
$arr = [1, 2, 3];
echo count($arr); \
A. 1
B. 2
C. 3
D. Error
Which function is used to remove whitespace or other characters from the beginning and end of a string?
A. strtoupper
B. strtolower
C. trim
D. str_replace
What is the output of the following code snippet?
echo date("Y-m-d H:i:s"); \
A. Current date
B. Current time
C. Timestamp
D. Error
Which function is used to search for a specific value in an array and return its key?
A. array_search
B. in_array
C. array_keys
D. array_count_values
What is the output of the following code snippet?
$str = "Hello World!";
echo strrev($str); \
A. !dlroW olleH
B. Hello World!
C. Error
D. Null
Which function is used to format a number with grouped thousands? A. number_format B. floor C. round D. ceil