Learning PHP + a small WIP PHP5 Manual

One of the interviews I'm currently doing to search for a new job is for developing with PHP/MySQL/Linux.

While this could seem shocking at first (just looking at the tag cloud on the right of the blog anyone can see I'm a .NET developer), it's not the first time I switch from languages (I've professionally worked with VB6, ASP 3, VB.NET, C#, ASP.NET and a bit of C++), and the company seems interested on me (mostly because I would have to learn almost from scratch).

But apart from having multiple interviews, it was logical to perform a code test. I did it yesterday (via email, sent two hours later as complete as possible in so tight timeline), and although I have yet much PHP to learn, I can start to make an oppinion of it.

PHP is not bad, in fact I had fun developing with it, it just suffers the "Visual Basic syndrome": in the past was so bad that has legacy problems and bad habits, and some features that need further improvement.

Object orientation of the language is ok, far from .NET but allows a lot of stuff. The biggest problem is the absence of namespaces concept, which leads to either awful class naming with underscores or having to take extra caution when deciding classnames.

But the inherited bad old stuff allows things like this:

class SampleClass
public $name = "";

$myClass = new SampleClass();
$myClass->namee = "Kartones"; // typo here on purpose

Guess what happens? "namee" is added on-the-fly to myClass object!!! Dynamic property creation should be at the very least restricted!

The syntax is a bit strange, and has some "exceptions", like this example:

$this->myProperty = 5; // Access current instance property
self::$staticProperty = 5; // Access a static property
$this->subObject->subObjProperty = 5; // Access a object property's property
parent::subObject->subObjPropert = 5; // Access parent class object property's property

Clear, uh? the use of "::" is supposed to be for static methods/properties, and "->" for instance ones, but then "::" is used too to access base class instance :P

But apart from that, it is interesting and once you know those delicate things, is not hard to develop with it. I've spent three days and done some small stuff (like implementing a few design patterns or manipulating images).

I don't discard doing something combining .NET (for the BLL/DAL part) and PHP (for the "presentation layer") to see how they work together.

The 5.2.8 version runs fine as a ISAPI filter under IIS (tested on 5.1 IIS), and all the code was written with Notepad2 (like the Windows original one but with syntax highlighting). Just make sure to read both the manual installation instructions AND the comments (I forgot to add a system variable to PHP's path and it was getting a "default configuration" instead of the correct PHP.ini one!).

Finally, as one of my habits at university, I've started writing a small PHP manual (oriented to C# devs.). I plan to update it as I go along learning more PHP.

The latest version of the manual can be found here (at the time of this post, just V.0.1 ;)

Tags: Development

Learning PHP + a small WIP PHP5 Manual published @ . Author: