Bird
0
0

Find the error in this PHP code:

medium📝 Debug Q6 of 15
PHP - Operators
Find the error in this PHP code:
$a = 5;
$b = 3;
echo $a ** $b;
AThe ** operator is invalid in PHP
BVariables should be declared with var keyword
CMissing semicolon after variable declarations
DNo error, code outputs 125
Step-by-Step Solution
Solution:
  1. Step 1: Check if ** operator is valid

    In PHP, ** is the exponentiation operator, valid since PHP 5.6.
  2. Step 2: Verify syntax and output

    Code is correct and outputs 5 to the power 3 = 125.
  3. Final Answer:

    No error, code outputs 125 -> Option D
  4. Quick Check:

    Exponentiation operator ** works in PHP [OK]
Quick Trick: Use ** for exponentiation in PHP 5.6+ [OK]
Common Mistakes:
  • Thinking ** is invalid
  • Missing semicolons
  • Using var keyword incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes