Operators and Expressions in PHP
1. What will be the result of the following
PHP expression? $var = 10 + 5 * 2; echo $var; a) 20 Answer: b) 20 2. Which operator is used for equality
comparison in PHP? a) = Answer: b) == 3. What is the result of the following PHP
code? $x = 10; $y = 5; echo $x % $y; a) 0 Answer: a) 0 4. How do you concatenate two strings in PHP? a) + Answer: b) . 5. What will be the output of the following
PHP code? $var1 = true; $var2 = false; echo $var1 && $var2; a) true Answer: b) false 6. Which operator is used to check if two
values are not identical in PHP? a) != Answer: b) !== 7. What will be the result of the following
PHP code? $val = 10; $val += 5; echo $val; a) 5 Answer: c) 15 8. What does the || operator do in PHP? a) Logical AND Answer: b) Logical OR 9. What will be the result of the following
PHP code? $a = 10; $b = 5; echo $a / $b; a) 2 Answer: a) 2 10. How do you increment a variable by 1 in
PHP? a) $var = $var + 1; Answer: d) Both b) and c) 11. What is the result of the following PHP
code? $x = 5; $y = "5"; echo $x === $y; a) true Answer: b) false 12. Which of the following operators is used
to perform bitwise operations in PHP? a) && Answer: c) & 13. What will be the output of the following
PHP code? $var = 10; $var *= 2; echo $var; a) 20 Answer: a) 20 14. What will be the result of the following
PHP code? $a = 4; $b = 2; echo $a ** $b; a) 6 Answer: b) 8 15. Which of the following statements is true
about the & operator in PHP? a) It is used for logical AND operations. Answer: b) It is used for bitwise AND operations. 16. What will be the result of the following
PHP code? $x = 10; $y = 5; echo $x > $y ? "Yes" :
"No"; a) Yes Answer: a) Yes 17. How do you perform a bitwise OR operation
in PHP? a) | Answer: a) | 18. What is the result of the following PHP
code? $var = 20; $var /= 4; echo $var; a) 5 Answer: b) 5 19. What will be the output of the following
PHP code? $a = 5; $b = 10; echo $a <=> $b; a) -1 Answer: a) -1 20. What is the result of the following PHP
code? $x = 10; $y = 20; echo $x & $y; a) 10 Answer: a) 0 21. What will be the result of the following
PHP code? $a = 15; $b = 4; echo $a % $b; a) 3 Answer: a) 3 22. Which operator is used to perform
exponentiation in PHP? a) ^ Answer: b) ** 23. What is the result of the following PHP
code? $x = 7; $y = 10; echo $x < $y && $x != $y; a) true Answer: a) true 24. Which of the following PHP operators is
used for string concatenation? a) . Answer: a) . 25. What will be the result of the following
PHP code? $x = 5; $y = 3; echo $x-- + ++$y; a) 9 Answer: a) 9 26. How do you perform a logical NOT
operation in PHP? a) ! Answer: a) ! 27. What will be the output of the following
PHP code? $var = 8; $var += 3; $var -= 5; echo $var; a) 6 Answer: a) 6 28. What is the result of the following PHP
code? $a = 7; $b = 3; echo $a ** $b; a) 21 Answer: b) 343 29. Which operator is used to perform bitwise
XOR in PHP? a) & Answer: c) ^ 30. What will be the result of the following
PHP code? $x = 3; $y = 2; echo $x ** $y; a) 5 Answer: b) 9 31. Which of the following PHP operators is
used to perform a logical AND operation? a) && Answer: a) && 32. What is the result of the following PHP
code? $var = 5; $var -= 2; $var *= 3; echo $var; a) 9 Answer: c) 9 33. What will be the result of the following
PHP code? $x = 5; $y = 10; echo $x == $y ? "Equal" : "Not
Equal"; a) Equal Answer: b) Not Equal 34. How do you perform a bitwise left shift
in PHP? a) << Answer: a) << 35. What is the result of the following PHP
code? $x = 5; $y = 5; echo $x === $y; a) true Answer: a) true 36. Which of the following operators is used
for assignment in PHP? a) == Answer: b) = 37. What will be the result of the following
PHP code? $a = 6; $b = 4; echo $a & $b; a) 6 Answer: c) 4 38. What does the !== operator do in PHP? a) Checks if two values are not equal. Answer: b) Checks if two values are not identical. 39. How do you perform a bitwise OR operation
in PHP? a) | Answer: a) | 40. What will be the result of the following
PHP code? $var = 12; $var /= 4; echo $var; a) 3 Answer: a) 3 41. What will be the result of the following
PHP code? $x = 15; $y = 3; echo $x / $y + $x % $y; a) 7 Answer: b) 10 42. Which operator is used to check if a
variable is not empty in PHP? a) ! Answer: d) empty() 43. What will be the result of the following
PHP code? $x = 8; $y = 5; echo $x + $y / 2; a) 10 Answer: d) 10 44. What is the result of the following PHP
code? $x = 7; $y = 3; $z = 5; echo ($x + $y) * $z; a) 50 Answer: c) 50 45. How do you perform a bitwise right shift
in PHP? a) << Answer: b) >> 46. What will be the result of the following
PHP code? $x = 8; $y = 4; echo $x % $y + $y; a) 4 Answer: b) 8 47. What is the result of the following PHP
code? $x = 3; $y = 2; $z = 1; echo $x + $y * $z; a) 6 Answer: b) 5 48. Which operator is used to perform a
logical OR operation in PHP? a) || Answer: a) || 49. What will be the result of the following
PHP code? $x = 5; $y = 10; echo ($x < $y) ? "Yes" :
"No"; a) Yes Answer: a) Yes 50. What is the result of the following PHP
code? $a = 2; $b = 3; $c = 4; echo $a * ($b + $c); a) 14 Answer: d) 20 51. Which operator in PHP is used to perform
a modulus operation? a) % Answer: a) % 52. What will be the output of the following
PHP code? $x = 5; $y = 2; echo $x ** $y; a) 10 Answer: b) 25 53. What will be the result of the following
PHP code? php Copy code $a = 10; $b = 4; $c = 3; echo ($a - $b) * $c; a) 18 Answer: a) 18 54. How do you perform an addition assignment
in PHP? a) $var += 5; Answer: a) $var += 5; 55. What is the result of the following PHP
code? $x = 10; $y = 5; echo $x <=> $y; a) -1 Answer: c) 1 56. What will be the result of the following
PHP code? $val = 8; $val -= 3; $val /= 2; echo $val; a) 2 Answer: d) 2.5 57. Which operator is used to perform bitwise
AND in PHP? a) | Answer: b) & 58. What is the result of the following PHP
code? $x = 6; $y = 3; echo $x / $y * 2; a) 4 Answer: d) 4 59. What will be the result of the following
PHP code? $a = 5; $b = 5; echo $a == $b ? "Match" : "No
Match"; a) Match Answer: a) Match 60. What does the += operator do in PHP? a) Assigns the value of the right operand to
the left operand. Answer: b) Adds the right operand to the left operand and assigns the
result to the left operand. 61. What will be the result of the following
PHP code? $x = 12; $y = 5; echo $x % $y + $x / $y; a) 2.4 Answer: c) 8.4 62. Which PHP operator is used to perform a
bitwise NOT operation? a) ! Answer: b) ~ 63. What will be the result of the following
PHP code? $a = 5; $b = 10; $c = 2; echo $a * $b / $c; a) 10 Answer: d) 25 64. Which operator is used to perform a
bitwise left shift in PHP? a) << Answer: a) << 65. What is the result of the following PHP
code? $x = 4; $y = 3; echo $x ** $y; a) 27 Answer: a) 64 66. How do you perform a bitwise right shift
operation in PHP? a) << Answer: b) >> 67. What will be the result of the following
PHP code? $a = 10; $b = 5; $c = 2; echo ($a + $b) % $c; a) 1 Answer: b) 0 68. Which PHP operator is used for
concatenating strings? a) + Answer: b) . 69. What will be the result of the following
PHP code? $x = 7; $y = 3; echo $x / $y + $x % $y; a) 4 Answer: a) 5 70. What is the result of the following PHP
code? $x = 8; $y = 2; $z = 3; echo ($x - $y) * $z; a) 6 Answer: b) 18 71. What will be the result of the following
PHP code? $a = 15; $b = 6; $c = 2; echo ($a - $b) / $c; a) 4 Answer: b) 4.5 72. Which operator is used to check if two
values are identical in PHP? a) != Answer: c) === 73. What will be the output of the following
PHP code? $x = 4; $y = 2; $z = 3; echo $x ** $y + $z; a) 19 Answer: a) 19 74. What is the result of the following PHP
code? $x = 5; $y = 7; echo $x + $y * 2; a) 12 Answer: b) 19 75. What does the && operator do in
PHP? a) Performs a bitwise AND operation. Answer: b) Performs a logical AND operation. 76. What will be the result of the following
PHP code? $x = 6; $y = 2; echo $x % $y * $y; a) 4 Answer: b) 0 77. What is the result of the following PHP
code? $a = 5; $b = 2; echo $a ** $b; a) 7 Answer: c) 25 78. How do you perform a modulus operation in
PHP? a) + Answer: d) % 79. What will be the output of the following
PHP code? $x = 8; $y = 3; echo $x & $y; a) 11 Answer: c) 0 80. What is the result of the following PHP
code? $x = 10; $y = 4; $z = 2; echo ($x + $y) / $z; a) 7 Answer: b) 7 |