Reputation: 285
I'm having problems embedding php inside an html file.
I first ran in to this problem when I was trying to 'include' a php file inside tags, and thought it was related to css formatting, or something. But now I've broken this down into the simplest php and html possible, with an example from a book that should work, and I'm still getting this problem. Here's the html sample that doesn't work:
<HEAD>
<TITLE>PHP inside HTML tester</TITLE>
</HEAD>
<BODY>
<?php
echo "Hello World";
?>
</BODY>
</HTML>
I'm expecting 'Hello World' to show up in my browsers, but nothing is displayed. When I try to 'view source', I see exactly the text above. I figure that after all the examples of this I've tried, the code is ok, but something is keeping what's inside the from being recognized.
Any suggestions? And thanks for helping me out with what's probably a dumb question.
Upvotes: 1
Views: 2546
Reputation: 163308
There is something wrong with your PHP installation. The web server isn't passing requests for PHP pages off to the PHP interpreter.
If you did indeed save the file as an .html
file, then your PHP code will never execute because most web servers have their handler mappings set to route only PHP (.php
, .phtml
, or .inc
extensions) files to the PHP interpreter.
Upvotes: 7
Reputation: 50840
Looks like your server is not able to handle php or your server does not know how to handle the file type with - this code is in.
Upvotes: 1