Parsing PHP in HTML

I have found a neat little trick I am going to share with you. It involves using PHP in HTML documents and this can be very helpful in many ways. Below I will explain the process and why it can be so important.

First let me talk about a few reasons why.

If you are a developer that needs to change a website to php from html.  This change can lose you valuable links to pages that will now have .php instead of .html and you will lose these links. ( Part of what I will explain will change this effect)

If you want to streamline design and have a common footer or common header.(Easily place a php include tag and place anything you want anywhere and just edit one page.)

If you want to use php stats. Now you can run php in a .html page. The list could go on and on.

The process is simple:
(NOTE: Most servers will allow this to work, if not check with your server administrator.)

First We make a .htaccess File

  1. Look for the file named .htaccess. If it’s not there, create a blank page using NotePad or Dreamweaver and save it as .htaccess
  2. Edit this file by adding the following lines:

code:                   –>AddType application/x-httpd-php .php .htm .html<– (copy paste between the arrows)

Save and close the .htaccess file. Upload it to your webserver or ftp  (to your WWW root) and your done.

Now we create a test page to see if its working on your server.

  1. We need to test it so lets make a test file.
  2. Open notepad or dreamweaver and save a file called test.html
  3. Now open this file and Insert the html below.
<html>
<head></head>
<body>
  <h1>
  <?php echo "Carlo from LiveNetNow taught me a neat trick"; ?>
  </h1>
</body>
</html>


(Now Upload this file test.html to your server and go to it via
 your web browser and there it should be!)

You now can have HTML pages that are run like php and have all
the capabilities of parsing php in them. 

This opens the doors to numerous capabilities and I will be
sharing a few with you in later posts be sure to come back and learn some techniques.

If your webhost doesnt allow php then you should shop around. 

Have Fun Coding,

Carlo DiTucci

CEO/President

http://www.LiveNetNow.com

Web Design/Web Hosting/SEO

529 One Center Blvd. Suite 211

Altamonte Springs Florida 32701

carlo@livenetnow.com

(407)-953-5167
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.