I got below error on my category pages and product pages after setting minify html to yes:
Parse error: syntax error, unexpected ‘<‘, expecting end of file” magento2 production mode
What should i do?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.Sign up to join this community
The cause of such errors is hidden in the template files. In the following commented code
1 <?php //echo "this is an unwanted php code";?>
there is no space between the semicolon “;” and the closing tag of php i.e. “?>” which causes the error.
For the above code, when the HTML file is minified, the closing tag of php is considered as a part of the commented code which is not included in the minified file and throws the error.
So, while commenting a php code in a phtml file, make sure that there is a space before the closing tag of php as done in the code below-
1 <?php //echo "this is an unwanted php code"; ?>
Doing this will avoid the error due to minification of HTML file.
Hope this will help you.