PHP is awesome. Itís widely used, has its roots in true system programming languages like C and has perhaps the best and biggest development community. While I donít claim to be a PHP expert, I did spend 4 years making my living as a LAMP ( Linux, Apache, MySQL, PHP ) developer.
When I first began coding, it was a horrible mess and yes, the first thing I ever coded was ďHello World!Ē I didnít declare variables, didnít comment code and certainly didnít bother writing functions or classes to make my job easier. I remember the first time I found a function to write the date on the bottom of my web site and I thought it was the coolest thing since sliced bread! Naturally, as time went on I learned to utilized functions to make my job easier, made beautiful descriptive comments and even declared my variables. As I took on bigger and bigger projects, my code had to improve as it became too time consuming to do things the way I had been doing them.
Once I had mastered functions, I moved onto Object Oriented Programming, in other words, PHP Classes. When I first started utilizing classes in my work, I was like Columbus discovering the New World. My coding life became a breeze and I was completing projects in record time with beautifully formatted code that was fast! I utilized classes for database interaction, time formatting, file and image based functions, networking functions and more. I worked with so many amazing PHP classes during my time as a freelance developer, however, I think the best class I ever came across was the Smarty Template Engine. So, now that Iíve exhaustively gone on about myself for what seems like ages, I will get to the meat and potatoes, Smarty.
If you are not familiar with template engines, there purpose is to allow developers to separate front-end code with back-end code. This allows a designer or design team to create and modify the graphical front-end of a web application without affecting the back-end PHP code. There are a lot of different template engines out there such as patTemplate, PHPTAL, FastTemplate, SimpleTemplate, Savant and more. I personally used both patTemplate and FastTemplate, however, none of them seemed to have the flexibility and extensibility of Smarty. Interestingly enough, the developer of FastTemplate also loves Smarty, which you can see from this post. Smarty is really much more than a simple tag replacement class, in fact, itís more of a template framework.
If you are new to PHP templates, you might feel like learning Smarty is like learning an entirely new programming language. If youíve ever worked with Cold Fusion, it will make a lot of sense to you as itís a tag based syntax. Smarty is also very familiar to PHP developers as its variable prefix uses the familiar dollar sign ($) and its if, then, else statements also work similarly to PHP. Smarty has an enormous catalog of functions that allow developers and designers to get very creative with their presentation layouts in addition to providing developers with enormous flexibility. I would argue that the best, albeit most dangerous capabilities of Smarty is that it allows execution of PHP code directly within the template. If you are a developer and possess full control over your codebase, I would never recommend this. If, however, you are working on an encrypted third party application that uses Smarty, you will be limited to editing only the templates and then having PHP coding capabilities can be absolutely wonderful.
Smarty is a very easy system to deploy, does not require additional system resources and integrates with any PHP deployment. Smarty is a system that many of us SolarVPSers know well and its easy to deploy on any VPS or Dedicated Server running cPanel or Plesk. Smarty can even be installed on Windows!
Object Oriented Code (AKA PHP Classes) add simplicity to medium to large complex sites.
But, it also adds unnecessary complexity to simple sites.
Sometimes you don't always need to use them ;-)
█ Owner Media-Hosts.com AS14442 Canadian Web Hosts Since 2002
█ 24/7 365 Support, 100% Network Up-time Guarantee
█ Web Development Specialists (E-Commerce, Inventory, Design)
█ OpenVZ.ca Reliable, Affordable VPS Servers and Web Hosting. IPv6 Available
When I started my new job in London, just knew a little info about functions and how to use them properly.
7 months later and I'm now writing self-correcting OO that requires very little maintenance. This smarty system looks interesting, could come in handy when I'm asked to work on a small website project again.
Who DIDN'T get their start by using 'hello world' examples? I still use that to test cgi-bin directories which have nasty permissions and problems.
I have to agree that php is pretty awesome and smart. Couple it with MySQL and you can do pretty much anything. At one point (12 years ago or so), I started working on a MUD (look it up ), trying to get the backend to tie into MySQL so staff could edit things through a CMS , and just haven't stopped playing with php/MySQL ever since. If you know what you're doing, it can do everything from monitor your server to chat (AIM, etc) to tweet to text message.. There are a number of things that make it just great at what it is.
It's one of the more common languages because of it's power -- that is not to be argued. Though I do believe that developers interested in the long haul of the industry must familiarize themselves with other languages and frameworks as well (such as .NET).
At some point in your career as a web developer, you will be asked to program in something other than PHP. Being an asset includes the ability to adapt to different situations well. As a result, it is strongly recommended that web developers not limit themselves to a single language but rather open themselves to constantly learning new things and discovering the power in knowing all of the options. :-)
We moved away from PHP some time ago and only use a couple things in PHP. These days it is all about ColdFusion (CFML) - If you like PHP and want to learn a second language would highly recommend ColdFusion!