How to embed PHP scripts?
By default, the HTML Egg App generates and uploads files with the"html" extension and these files are processed by the web server as HTML files.
For advanced users who wish to add segments of PHP scripts into the web page, this is possible with HTML snippets and a few quick web server level setting changes.
Step 1. Add the PHP script into a HTML snippet. Make sure this code is wrapped in proper PHP syntax with <? and ?> tags opening and closing the code.
If you are testing this out, try the following line of code:
<? echo" I am printed from PHP!"; ?>
Step 2. Make changes in the .htaccess file on the web server to process HTML files as PHP files. This is an important step, and remember since this change is only recommended for advanced users, if you do not know what an .htaccess file is, we suggest contacting your web host provider for support.
Add the following line into the .htaccess file:
AddHandler application/x-httpd-php5 .php .html
Make sure you have a backup of the file so we can revert the changes if needed. This line tells the server to process HTML as PHP files and lets us embed PHP segments into the page. It's also assumed that PHP5 is available on the server, PHP5 is the most popular PHP version offered by hosts nowadays.
Step 3. Test to make sure PHP is now working. If you tested with the sample code in Step 1, you should see the line "I'm printed from PHP!" on the web page after it's uploaded.