Reputation: 3
https://i.sstatic.net/L9SYq.jpg
I have an HTML page with embedded PHP:
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>HTML with embedded PHP</title>
</head>
<body>
This is normal HTML code
<?php echo " Scooby Doo "; ?>
Back into normal HTML
</body>
</html>
results in the php code being commented out when viewed on the testing server:
<!--?php echo "Scooby Doo"; ?-->
The server is localhost and running a fresh install of WAMP. Has anyone any ideas as to how to get my php code to parse correctly in the HTML?
Tried it in IE but same results. Tried it on another server XAMPP and got the same. Running Windows 10. Is it an application permissions thing with apache?
PHP runs fine - have made a php page calling <?php phpinfo(); ?>
and it works.
I'm stumped. Thanks.
Upvotes: 0
Views: 515
Reputation:
Simply you can't do it. Your HTML page cannot be interpreted as PHP script by the apache web server, because it doesn't recognize as a valid PHP extension. Try add this line to your .htaccess
file
AddType application/x-httpd-php .htm .html
This simple line will tell your apache web server to handle also .html as PHP script.
But however, you should rename your file using .php
extension and you solved the problem
Upvotes: 1