Why build all your web pages in PHP?

I recently had this question put to me by a web designer who was considering the idea of using PHP pages in her websites:

“Why build all your pages in PHP … Why not use standard .html pages?”

She then expanded the question to:

“What I mean is…… what’s the benefit to building ALL sites in PHP?”

Note to uber-nerds: remember that this question is being put to me by a web designer who has never written software. As such the answer is tailored those who are new to programming.

I might tackle this question from another perspective if the question was put to me by an experienced developer.

PS: If you find my answer offensive to your nerd-sensibilities, you might want to read this.

The Answer:

By making all your web pages PHP pages from the start, you are basically leaving open the possibility of using PHP in your web pages at any time.

… You don’t want to (at some later date) have to go back and change your .html pages to .php. For example:

  1. my-product-list.html
  2.  
  3. … becomes:
  4.  
  5. my-product-list.php

Beginners should note, that you need to have .php extension on any web pages where you want to use PHP. Check out my basic PHP videos for details.

-

PHP can do a lot more than just talk to MySQL. One very common use of PHP is to create ‘includes’ … this will allow you to insert snippets of code in your pages from separate files. This is kinda like using external CSS files. So you can use PHP includes to say create your page footers.

You can learn more about PHP includes in my free videos.

In the end, by making all your pages php pages from the start, you will just have a more flexible website to work with since you will be able to access PHP’s power.

Stefan Mischook

www.killersites.com


This entry was posted on Thursday, May 15th, 2008 at 2:29 pm and is filed under Beginners PHP Articles. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

9 Responses to “Why build all your web pages in PHP?”

  1. Stefan Mischook says:

    In response to an attack by a bunch of nerds, I should point out that you can use .htaccess to allow for php code to be processed in HTML.

    Just add this line to your .htaccess file:

    AddType application/x-httpd-php .htm .html

    This will not work (as far as I know) on an IIS web server though.

    Regardless, it is probably a bad idea to introduce things like .htaccess to someone who doesn’t know what a variable is. One step at a time.

    Stefan

  2. parad0x says:

    Calling people smarter than you “a bunch of nerds” it’s not nice.
    Oh and btw… for how long have you been a php pro-gamer? 1 year maybe? oh, excuse me 2?

  3. Stefan Mischook says:

    Hi,

    I wrote my first Java based web application around 1998-1999. Before that, I used ASP a lot. In between then and now I’ve developed software with a few languages and frameworks including:

    - C# (asp.net)
    - VB.net
    - Java (JSP, servlets and some other frameworks)
    - web objects
    - Classic ASP
    - PHP

    … and I dabbled in others.

    -

    It’s nice to see that the PHP community has embraced things like MVC and other proven design patterns.

    It’s also nice to see that we now have mature web frameworks like The Zend Framework and Cake out there too.

    Back in the day, us Java nerds had to deal with really heavy frameworks that made Java a real pain in the butt to work with. I personally saw EJB 1 and 2 for what it was and stuck to POJO’s, and Model 2 development (MVC) using servlets and JSP’s. I tried various MVC frameworks that were out at the time but I just never got into them … especially Java Server Faces! What a mess.

    Not until the Spring Framework and the introduction of Aspects, did we see Java start to lighten up a little.

    .. Of course, we’ve had servlet filters (since 2.2) that expressed the same pattern (filter, decorators) before Spring and Aspects came into the equation. Though I should point out that servlet filters worked on a higher level on the stack …

    So parad0x, what have your experiences been with filters and Aspects?

    Stefan

  4. parad0x says:

    Dear Stefan,

    You got me all wrong. What I wanted to point out was that using such a language will never bring you any kind of respect from anyone. I arrived on this page from some other weblog on which was discussed a very popular kind of subject nowadays (unfortunately), the my-language-is-better-than-yours type of subject, and felt very offended by the fact that the people which lead less or more important web comunities nowadays (such as your e-learning website) express their thoughts in such a maneer (and masses of people which visit/use your website for learning PHP might more or less adopt the same oppinion you have about these so-called -nerds-); and I’m sure if you thought a bit before posting this, you could come up with something more diplomatic and self-respecting.
    Regarding your article (or tutorial), I didn’t even read it. By saying this I don’t want to offend you in any way (or the PHP language and/or community). I’m just not interested in such subject as I’m not a web developer (designer/coder or anything like that) and I have a certain level of experience so I’d just waste time; I’m a software developer. In spite of the fact I’m a software developer/it security engineer, I came in contact with the majority of web-intended scripting / programming languages, and even developed a huge (as in software terms) back-end system for a very popular international company in 2000 which is extensively used successfuly even nowadays (of course it was refactored and updated to certain points) using Python, and I have to say that I totally disagree with your point of view on the maturity of the mentioned PHP frameworks Zend and Cake (the last one I would call even infantile). Of course this doesn’t mean they won’t evolve but there is a very long and tedious road ahead, but here we’ll be, watching over.
    One thing is very important though, which is very often missed in these language wars, if you are a good coder you will always know to use the right tool for the right job. Even if this is not my branch I have succesfully used Python, Ruby, PHP and even .NET (and be aware that when I say -used- I don’t mean the kind of application that extracts information from a database, lets you modify it, and then posts back the new information, I’m talking about medium-to-large scale enterprise-level applications) and never even thoght about comparing one language to another. Of course every language has is strong and weak points but,in my oppinion, a coder which compares languages and arrives upon conclusions like PHP is better than Ruby because…, or Ruby is better than PHP because… is like a carpenter which would only want to use the hammer for every job he has to do and renegate all the other tools saying that they suck in comparison with the all-mighty hammer.

    Regards,
    0x

  5. Stefan Mischook says:

    parad0x,

    You are right, I did misunderstand what you were saying.

    A couple of points:

    Nerds are cool:

    When I used the term ‘nerd’, I don’t mean to denigrate, make fun of or put down tech savvy people. After all, I fall in that category myself to a certain extent.

    When I use ‘nerd’, it is just there to add color to the writing and in fact, I use that word to describe myself with a certain sense of pride … given how much of a positive impact that nerdness has had on the world, how can nerds not have pride!

    About programming languages:

    I agree, you should choose the right language/framework for the job at hand. I have been doing this in practice for many years. I am married to no single language – I never have been.

    That said, I think for web designers and people NEW to programming, who want to learn how to add dynamic capabilities to web sites, PHP is the choice today.

    I am not saying PHP is the ultimate and only solution , that would be a crazy thing to say about any language or framework. But again, for web designers looking to do all those common dynamic web things … PHP is really hard to beat, when all things are considered.

    About the PHP frameworks:

    I did not speak clearly. I was meaning to say that the concepts behind Zend and Cake (although I barely looked at Cake, so I can’t say anything about it) … are far more mature than we’ve seen in the past from PHP.

    Zend is very young (we leveraged a beta last year,) but it shows promise and has good things about it.

    You have to give the PHP community a break, Java is still (as far as I know) trying to work things out after all these years.

    Remember the mess that was EJB, applets, Swing …

    Thanks for posting.

    Stefan

  6. Camilo says:

    Dear Stefan:
    First I have to thank you because I have learned more with your free vids than anywhere else. PHP is such an attractive language because it really puts the load of work on the server side, which I think might be the future of RIA’s and of course in the future when everybody is connected we will be seeing the use of the internet as a platform and i believe PHP is going to be king. I find PHP very important in web development but more importantly is the fact that we are reaching a point where designers and programmers are starting to find their jobs entangled if you will. This is particularly my case, where I am trying to apply my artistic skills as a visual artist on the field of web design. As an artist I have found myself learning Actionscript and also PHP. Actionscript because if you are to use the Flash authoring program you gotta know a little bit of such language. PHP is just as important if you wish to make your websites dynamic enough and also have the ability to handle feedback from your users…so, from an artist point of view, as the web grows and transforms into a platform web designers (where design stands for artistic visual perception) are becoming basically pushed to learn programming at least in its basic forms.

  7. Stefan Mischook says:

    Hi Camilo,

    I’m happy to hear that the videos have been useful to you.

    I also have Actionscript videos too – I just released a new video that show you the differences between Actionscript 1, 2 and 3:

    http://www.killersites.com/flash/videos/actionscript-evolution.php

    … I hope you find it useful.

    Stefan

  8. avengingwatcher says:

    Stefan,
    I don’t get where people who contribute absolutely nothing to the community get off. parad0x (you can tell he’s cool cus he uses uber-1337) seriously unless you have a better site that is free to use for the betterment of society and web development in general, go to hell. The fact that Stefan gives away this information on multiple sites at his own expense and asks nothing in return is enough for you to show him some damned respect. It’s arrogant asses like you that make the development community suck. Stefan has the right to his opinion either way, and guess what it’s HIS damned site. You don’t want to read it or your disagree, start your own site…oh right too busy trying to inflate your own ego, you can build big things for the interwebs…awww isn’t that special, hey as a former carpenter let me let you in on a little secret, you only have two hammers you use and you use them for different things entirely, it’s more akin to web development vs. software development. Not even working on the same type of thing.

    Stefan I apologize but these kinds of pompous bastards annoy me. Of course you use the right tool for the job, but you know what everyone has to start somewhere and PHP is the way of the foreseeable future. I for one completely agree that just about any application that the lay web developer would need can be found within the PHP framework. I wouldn’t say it has fully matured yet, but where it is from where it was is far and away a great statement as to the prospects for the future. We are working with new technology that changes in the blink of an eye and keeping abreast of these changes becomes harder and harder to manage sometimes. I think that the majority of web needs have been adequately met with our current physical infrastructure but within 10 years or so our whole way of doing things will change again to become and infinitely more customizable experience. As this changes our user experience, more and more of the non-tech community will be forced to rely on the wisdom and understand of those of us who are experts in the field. We have to remember and focus on the fact that we are not only people interested int the framework but also the first line of customer service that often goes unnoticed, much like the designers of cars with well thought out interfaces, if you have to think about where something will be the interface has not fully completed it’s function. Once again, I applaud your dedication to an open community of sharing and helping one another, if coding isn’t open it turns into another UNIX fiasco where only the selct few know how to use it and guard that secret well, turning unix into the worldwide powerhouse that it…oh that’s right few people use it anymore as they can easily integrate a Linux Set-up OOP or even use the Windows computers they know and love. The point is that by sharing we put new blood and new life into what we love. Not only is this a lesson for developers but also for the global community at large.

  9. Chris Gardner says:

    Stefan,

    Thanks for your work. I have been trying to learn to be a programmer and its hard finding great sources. I am a web designer new to the industy, but I want to be well versed in everything. Can you give me some insight to Joomla! and also take a look at some of my work and just give me some pointers? I would greatly appreciate it. Thanks for all your help, and the great videos, please keep em comming!

Created By Stefan Mischook  |  Top of page  go to top of page