I have for some time been working on a test web site to add a hit/visitor
counter using PHP to no avail. I am hoping someone would look at my efforts and suggest what to try next.
Since your various attempts to include php code are just displaying in the browser, it means that the php engine is not parsing your page. The most likely reason is that the file name suffix is “shtml” and not “php”. Are you actually needing server side includes, or is that just part of an experiment? I’d rename the file to PHPTestWebSite.php and try again, then go from there.
I don’t think you can’t have both SSI and PHP in the same file. Each requires a separate pass of the code, so it would make it rather slow. I suggest you do your date echo in PHP and as @tracknut says, rename your file with a .php extension. (Edited)
Check to see if the website’s hit counter’s PHP code is correct and correctly implemented.
Verify that the file that contains the hit counter data has the appropriate file permissions set. The PHP script needs to be able to write to the file.
Ensure that the code for the hit counter is compatible with the PHP version being used. Certain functions used in the code may not work with some older versions of PHP.
Check to see if any required PHP modules are installed on the server and are active.
Verify the server logs and PHP error logs for any errors that might be connected to the hit counter code.
Check to see if the server’s or website’s caching systems are preventing the hit counter from working properly.
Instead of creating your own hit counter script from scratch, think about using a third-party service or pre-built script.