Home

Which change would correct the syntax error in the following code??

Alton Alexander
By Alton AlexanderUpdated on June 3rd, 2022

The error in this code is a missing semicolon ; on line 4. This error happens when the compiler reaches line 4 and expects a semicolon, but instead finds an open parenthesis.

1. Use a semicolon after 'echo'

echo "This is a semicolon"; echo "This is not a semicolon"; echo "This is a semicolon"; echo "This is not a semicolon";

2. Use double quotes around '$name'

'$name' should be double quoted Incorrect: '$name' should be double quoted

3. Add a semicolon after '$name = "Alex"'

$name = "Alex"; $name = "Alex"; Add a semicolon after '$name = "Alex"'

4. Use a semicolon after 'echo'

echo 'Hello, World!'; Hello, World!

5. Use double quotes around '$name'

$name = 'John';

If you didn't find success with an option above, then try: