In PHP, you can use the script tag to open a PHP block.
So you can use
So in your example you have mixed the normal open tag, , with the closing tag, . So the parser assumes that all the text after the closing script tag is normal HTML.
Read more in Escaping from HTML.