sanjihan
sanjihan

Reputation: 5992

incorrect php code output with embedded html

I am trying to implement html code in my php code. I use

<?php
echo <<< _END
//HTML HERE
_END;
?>

The problem is that _END;?> shows on the page as well.

I edited directives for my websites folder in /etc/httpd/conf.d/mywebsite.conf with this code and I access the php file with mydomain.com/test . No .php extension added. If I access mydomain.com/test.php than there is no _END;?> in my html output, which is correct.

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
#RewriteRule ^([a-z]+)\/?$ $1.php [NC]


RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html
#RewriteRule ^([a-z]+)\/?$ $1.html [NC]

</IfModule>

Any idea why am I seeing _END;?> in my website?

It seems that hiding .html works as it should, but .php gets incorrectly interpreted.

Upvotes: 0

Views: 50

Answers (1)

poohbear
poohbear

Reputation: 452

You have an extra white space before or after the _END. Here is a link that will explain it in more detail. heredoc

Upvotes: 1

Related Questions