Jump to content

Enable PHP code in HTML


lewmur
Go to solution Solved by Barand,

Recommended Posts

I'm an 83 yr old retired computer consultant and I'm trying to write a simple program to display info from a text file.  I'm running PHP8.1.2 from a Mint 21 box.  I have apache2 installed and modified the apache2.conf file to change AllowOverride to All.  I created the .htaccess file in the /var/www/html folder with the line AddType application/x-httpd-php81 .php .php5 .htm .html  If I run the PHP code in a .php file, it works fine.  But I want to change the white background to an image and the only way I see to do that is in HTML.  But when I put the PHP code in the HTML file, it just displays the code.  What am I doing wrong????

Link to comment
Share on other sites

  • Solution

PHP code must be in a .php file to be executed (with a standard configuration) However a .php file does not need to contain any php code, it can be html only. So any html you can do in an .html file should work in a .php file.

Define the background image in your css - it should work the same in either.

Link to comment
Share on other sites

4 minutes ago, Barand said:

PHP code must be in a .php file to be executed (with a standard configuration) However a .php file does not need to contain any php code, it can be html only. So any html you can do in an .html file should work in a .php file.

Define the background image in your css - it should work the same in either.

So simple!!!  I just save the .html file as a .php and it works!!  Thanks!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.