Skip to content
Advertisement

PHP switch statement problem causes a syntax error [closed]

My code:

JavaScript

This code gives me an error:

JavaScript

I know that I can avoid closing php tags and say echo 'text'; but still, how to fix this?

Advertisement

Answer

You are breaking the switch syntax off by outputting empty spaces when closing and opening the PHP tag.

This will work:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement