Embedded PHP in HTML- either PHP ignored or HTML broken
Please excuse this newbie question. I'm an experienced programmer with no experience in PHP.
I'm doing a website (on a Linux-hosted page on GoDaddy) where I'm trying to display a download count. A Google search told me that the easiest way is to use this PHP code:
<p>Count=<?php include("count.txt"); ?> </p>
This displays "Count=", but nothing else, so I tried another variation:
<p>Count= <?php echo file_get_contents('count.txt'); ?> </p>
That didn't work either.
I know that PHP is working because I set up the page to invoke a small PHP script to initiate the download, and that script correctly increments the contents of "count.txt" each time the download is done.
A further Google search revealed that the browser won't evaluate PHP code embedded within HTML unless the extension is changed to PHP. Unfortunately, in my case, doing this caused the browsers (Firefox, Chrome) not to display the page at all, but to bring up a screen asking what application to use to open this mysterious PHP file. So I then created an ".htaccess" file on my site which specified that HTML files were to be interpreted as PHP. Same result, except that all HTML files were broken in a similar fashion.
I must be doing something really dumb here, but my novice level prevents my from know how to phrase the question intelligently. How do I get this embedded PHP code to to parsed without breaking the HTML?
Thanks in advance for any help you can give me.
|