Life Programming

Changing Opinions – Why I Can No Longer Stand PHP

You can see my C# education has rubbed off a bit on my PHP programming, for example the use of Libraries and more comments than I would have previously used

My first experiance of programming was making dynamic web pages for Worldwide Lighthouses Version 2. Essentially all my project did was provide an uploader for images and data, which was then input to a database, and several different types of pages used to display information about different types of aids to navigation by pulling information from the database and formatting it in a specific way.

At the time I thought the language I was using to do this — PHP — was great, the syntax was simple and there was plenty of documentation avaliable online for free. I hadn’t had any formal tutoring, nor did I need it in order to get on with what I was doing, I taught myself and things worked… most of the time. Of course having no formal tuition I didn’t work under best practices and everything was absolutely linear, I had no concept of Object Orientation. These were the days when I loved PHP.

In fact, when I first started learning C# I thought it was downright stupid that you had to declare what type a variable contained, “Why can’t the stupid thing work out that ‘2’ is a number?” is a choice quote from myself.

Recently I’ve had to go back to PHP for a few projects, including 5Hives. I cannot stand it. Compared to C#, PHP is massively inconsistant — heres some examples:

  • Built in Methods – Some use Under_Score() naming, some use camelCase, some use number2syntax, some use numberToSyntax. This means you can never guess what a method you need might be called, especially annoying when dreamweaver and expression web don’t have very good intellisense.
  • Sometimes it prints errors to the browser, sometimes it puts them in an error log. Oh, and it doesn’t tell you where said error log is.
  • Some functions return null if they failed, some throw an exception causing the program to stop, some print errors… etc etc
  •  If you forget the $ sign before a variable, rather than telling you it uses the name of the variable as if it was a string
  • Don’t even get me started on sessions…

There are so many reasons that PHP isnt the nice “work place” that C# is that I cannot sum them all up — I’ll leave that to this much more in depth post, which I enjoyed reading and agreed with on the whole.

Just the other day Nick was saying how everyone loves the first language they learn, be that prolog, python or VB (ok, maybe not VB ;)) but I cannot count myself among this group. I can program in PHP quite well, I can tolerate it and I know there are some situations where it is one of the best tools to use (simple upload forms are still a joy to make in PHP) but I cannot say I’m its biggest fan.


Leave a Reply

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

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

Google photo

You are commenting using your Google 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

This site uses Akismet to reduce spam. Learn how your comment data is processed.