A. Variable names cannot contain uppercase letters
B. Missing semicolon after echo statement
C. Concatenation operator is incorrect
D. Variable names cannot start with a number
Solution
Step 1: Check variable naming rules
Variable names cannot start with a number. $1stName starts with '1', which is invalid.
Step 2: Verify other parts of the code
The concatenation operator . and semicolons are correct, and uppercase letters are allowed.
Final Answer:
Variable names cannot start with a number -> Option D
Quick Check:
Variable names must start with letter or _ [OK]
Hint: Variable names cannot start with digits, only letters or underscore [OK]
Common Mistakes:
Thinking uppercase letters are invalid
Confusing concatenation operator with plus sign
Missing semicolons causing errors
5. You want to store a user's age in a variable. Which variable name follows PHP naming rules and is the clearest choice?
hard
A. $userAge
B. $user-age
C. $age user
D. $2age
Solution
Step 1: Check PHP variable naming rules
Variable names must start with $ followed by a letter or underscore, and can contain letters, numbers, and underscores only.
Step 2: Evaluate clarity and correctness of options
$userAge uses camelCase with allowed characters. Options A and B contain hyphens and spaces, which are invalid. $2age starts with a number, which is invalid.
Final Answer:
$userAge -> Option A
Quick Check:
Clear, valid variable name with letters and no invalid characters [OK]
Hint: Use letters and underscores, no spaces or hyphens, start with $ [OK]
Common Mistakes:
Using spaces or hyphens in variable names
Starting variable names with numbers
Choosing unclear or confusing names
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.