PHP not working in HTML (new install)
Posted by: we5inelgr (---.172-78-65.rez.dyn.surewest.net)
Date: July 06, 2021 11:55PM

Hi All,

I just installed WAMP v 3.2.3.3 64 bits on my Windows 10 PRO laptop for the first time. I do not have IIS turned on as a Windows feature.

I'm trying to execute php code within an .html file. However, I can't get php to echo anything out.

File name extensions are shown, so I know it's an HTML (.html) file.

I modified my Apache .httpd.conf file like this (added the last line) and restarted all services:
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .html

I also changed my www folder by removing the default path in httpd-vhosts.conf (and restarted all services):

DocumentRoot "C:/Homepage"
<Directory "C:/Homepage/">

I have a file called index.html in that folder C:\Homepage\index.html with only these three lines in it:

PRE<P>
<? echo "PHP"; ?>
<p>POST

I have "short_open_tag" checked in the PHP setting of WAMP.

When I access that page in MS Edge Version 91.0.864.59 (Official build) (64-bit), all I see is "PRE" and "POST" printed on the page, but not "PHP"

If I only put this in that html file

<? phpinfo(); ?>

Nothing is displayed as well.


Any ideas why I can't get php to execute in an html file?

Thanks.



UPDATE - Nevermind smiling smiley I wasn't accessing the page via localhost/index.html



Edited 1 time(s). Last edit at 07/07/2021 12:16AM by we5inelgr.

Options: ReplyQuote
Re: PHP not working in HTML (new install)
Posted by: Otomatic (Moderator)
Date: July 07, 2021 09:02AM

Hi,
The files must have the .php extension

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons



Edited 1 time(s). Last edit at 07/07/2021 11:08AM by Otomatic.

Options: ReplyQuote


Sorry, only registered users may post in this forum.