Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

1. Which of the following is a superglobal variable in PHP?

a. $GLOBALS
b. $local
c. $variable
d. $this

2. In PHP, which function is used to get the length of a string variable?


a. length()
b. strlength()
c. strlen()
d. size()

3. What is the output of the following code snippet?


a. $x = 5;
b. $y = 10;
c. echo $x + $y;
d. 15
e. 510
f. 5 + 10
g. Error

4. Which of the following is true about variable names in PHP?


a. They are case-sensitive.
b. They cannot start with a number.
c. They can contain spaces.
d. They can contain special characters like @ and #.

5. What does the gettype() function in PHP return?


a. The data type of a variable
b. The value of a variable
c. The length of a variable
d. The scope of a variable

6. Which of the following is the correct way to assign a value to a variable in PHP?
a. $x = 5;
b. 5 = $x;
c. x = 5;
d. $5 = x;

7. What is the difference between single quotes (' ') and double quotes (" ") when defining strings
in PHP?
a. Single quotes allow variable interpolation, while double quotes do not.
b. Double quotes allow variable interpolation, while single quotes do not.
c. Single quotes and double quotes behave the same in PHP.
d. Single quotes automatically convert variables to strings, while double quotes do not.

8. Which of the following is the correct way to create a constant in PHP?


a. define CONSTANT_NAME = "value";
b. constant CONSTANT_NAME = "value";
c. const CONSTANT_NAME = "value";
d. $CONSTANT_NAME = "value";

9. What is the purpose of the global keyword in PHP?


a. To declare a variable as a constant.
b. To access variables declared outside the current scope.
c. To define a variable with global accessibility.
d. To restrict the access of a variable within a function.

10. What is the value of $x after executing the following code?


a. $x = 10;
b. function myFunction() {
c. global $x;
d. $x = 20;
e. }
f. myFunction();
g. echo $x;
h. 10
i. 20
j. Null
k. Error

11. What is the operator used for addition in PHP?


a. +
b. -
c. *
d. /

12. Which operator is used for concatenation of strings in PHP?


a. +
b. -
c. .
d. ,

13. What is the operator used to increment a variable by 1 in PHP?


a. ++
b. --
c. +=
d. *=

14. Which operator is used for assignment in PHP?


a. =
b. ==
c. ===
d. =>

15. Which of the following operators is used for strict equality in PHP?
a. =
b. ==
c. ===
d. !=

16. What does the "==" operator in PHP check for?


a. Identity
b. Equality
c. Reference
d. None of the above

17. Which of the following is the "not equal" operator in PHP?


a. <>
b. !=
c. !==
d. ><

18. What is the operator used for modulus division in PHP?


a. %
b. /
c. *
d. ^
19. Which operator is used for exponentiation in PHP?
a. **
b. ^
c. ^
d. ^^

20. What does the "===" operator in PHP check for?


a. Identity
b. Equality
c. Type and value equality
d. None of the above

21. Which operator is used for logical AND in PHP?


a. &
b. &&
c. ||
d. |

22. Which of the following is the "greater than or equal to" operator in PHP?
a. =>
b. <=
c. >=
d. ->

23. Which operator is used to access a member of an object in PHP?


a. .
b. ::
c. ->
d. []

24. Which operator is used for the ternary operation in PHP?


a. ?
b. :
c. ::
d. ->

25. What does the "!=="" operator in PHP check for?


a. Identity
b. Equality
c. Type and value inequality
d. None of the above

26. Which operator is used for logical OR in PHP?


a. &
b. &&
c. ||
d. |

27. What is the operator used for string comparison in PHP?


a. ==
b. =
c. ===
d. strcmp()

28. Which operator is used to concatenate and assign in PHP?


a. .=
b. +=
c. *=
d. -=

29. What does the "=>" operator in PHP signify?


a. Comparison
b. Assignment
c. Array key-value pair separator
d. Object method call

30. Which operator is used to determine if a variable is set and not null in PHP?
a. ?
b. ?:
c. ??
d. ?!

You might also like