How to call PHP script within HTML files

Catagories: CSS / Webdesign, GUI, Operating system, PHP, Programming, Windows, cPanel / February 26th, 2008

Will code HTML for food - God bless you!

First off : Why the heck should you have/use PHP?

PHP is server side scripting. That means it is parsed on the server before your page loads in the browser. To the visitor and to the search engines PHP scripts are not noticeable. When PHP is combined with RSS feeds, links, blog entries, dynamic portfolio, it is a pretty powerful concept. With PHP you can add other people’s content to your web pages and the search engines will see it and think it is part of your website! (Think of the SEO-thingies). That PHP-parsed content when placed on your web page will essentially become a part of your web site and bring you more traffic. That is why most web developers recommend that you add the content from external sites to your website with PHP instead of Javascript.

Which comes first? Chicken or egg?

The characteristic of HTML that it will only parse / call the Javascript from within the HTML-parsing routine. (Okay, we both know it can call whatever files, but for the sake of this post, let’s pretend it’s that way, okay :D ). PHP, ASP, JSP, whatever, can call/use HTML tags/files, and not the other way around.

Yes, I know that you can simply “rewrite” everything into php and enclose the real php in <?php … ?>-tag.
But how should you do it if you insist that the file’s extension is still HTML and still can parse the PHP scripts inside? There are some ways:

  • Option I
    • a: .htaccess for HTM/HTML, IIS
    • b: the same as Part I, only using the cPanel instead the hard way
  • Option II: SSI Include (more…)