PHP Include() Function vs Dreamweaver Templates

Finally found a reason to deploy PHP myself. Pretty stoked about it, too. As my studies continue, I'm sure there will be more such programming discoveries .. but today I grok'ed the beauty and the power of the » PHP include() functon [.. and its more restrictive cousin » require() ].

PHPYou might recall last year, how excited I was to learn how to use Dreamweaver Templates.

They allow you to change/update a single file (template) and have that change applied to EVERY webpage that is based on that template.

I even wrote a guide on how to use them that has become surprisingly popular » Rad Guide to Dreamweaver Templates

Dreamweaver Templates are similar to how CSS works, which allows you to change the look-n-feel of your entire site by editing a single file.

The ONLY PROBLEM with Dreamweaver Templates is that they require you to UPLOAD all the changed files (.. to your server). Which kinda suks. (Depending on how many files are affected by the change.)

Not so with the PHP include() function, which works more like CSS. In fact, it works exactly like CSS in that respect. Meaning, you only have to re-up a single file.

••• today's entry continues here below •••

So I could put all my header info in a single file, and all my footer info in another .. and code up a little PHP mojo using the include() function to call that (header/footer) file(s).

If I ever want to change the header or the footer or whatever (.. and this is something I've wanted to do MANY times over the years), all I need to do is edit the included (header/footer) file. And voila! Every webpage that calls those (included) files will be updated. No need to re-up each individual page. Too cool.

Earlier in my studies of the PHP language, I caught a glimpse of the possibilities. But it wasn't until today that I saw the full glolry of the PHP include() function.

Inside those parentheses are where you stick the path of the included file, such as:

<?php include("includes_files/header.php"); ?>

This has the potential to be a major boon to/for web designers. As your web skills improve, designers and developers would sometimes like to re-do the site. But if you have a large site, consisting of thousands of pages (like Radified) .. it's just physically impossible to go back and edit every page by hand. (Which is why I haven't done it.)

I'm still learning the language, but the include() function is reason enough (by itself) to learn PHP. It's that powerful. Better than Dreamweaver Templates. And there's probably more cool tricks to using the include() function that I haven't yet learned.

Plus Dreamweaver Templates muck up your mark-up with extra (proprietary) tags, while the PHP include() function actually lets you eliminate mark-up (.. and store it in a separate file).

With all that said, I shou,d probably add that it WAY easier to learn how to employ Dreamweaver's templating features than it is to learn PHP .. which I'm still doing.

For more along these lines, here's a Google search preconfigured for the query » php include function vs dreamweaver templates

About this Entry

This page contains a single entry by Rad published on June 2, 2010 6:02 AM.

The Deepwater Horizon Memorial was the previous entry in this blog.

TED | Ideas Worth Spreading is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.