Archive for the 'PHP' Category

Object-Oriented PHP 5 – just like Java

Sunday, October 19th, 2008

One of the best thing about PHP is how easy it is to learn.

If you come from Perl, you may have at times the feeling that “PHP is Perl for Dummies”  … as my Perl teacher liked to repeat.

If you come from Java, it is even better. PHP 5 OO concepts make it very close to Java, you can learn the few differences very quickly: the package concept in Java is replaced with namespaces in PHP, since version 5.3; the properties of an object are accessed with the awkward $this->myProperty.

Now, you can grab a book on PHP 5 objects, flip the pages and repeat: “just like Java”, “just like Java”, “just like Java.”

Why PHP?

Monday, January 1st, 2007

We already have Perl, we already have Java, and both claim they can do the job on the web. So why introduce another language? Why use PHP?

P stands for Pragmatic

PHP is just the smallest tool that gets the job done. Why use anything else than a hammer when you just want to pound a nail in the wall.

Together with MySQL, PHP provides a simple and complete web solution on the server side. It is simple: you can create very quickly a web prototype. It is also highly scalable: some of the largest web sites use PHP.

Whether the task is to generate HTML, manage sessions or interact with a database, PHP always comes with a very simple solution.

A simple language

Many languages have difficult concepts to grasp; some of them are even weird at times. This is not the case for PHP. In fact, if you know any modern language, you should be able to learn PHP quickly.

The simplest tool for the job

PHP is a simple scripting language and you can certainly write sloppy code with it. However if you want you can write highly maintainable code; actually, you can easily write object-oriented code. In fact, PHP 5 can look very similar to Java (with one big hole: no packages/namespaces).

The best feature

The best PHP feature may seem like a little thing. The big deal is that you can mix PHP tags and HTML tags: you can put PHP code inside HTML tags, and you can put HTML tags in PHP code. This makes it a very pragmatic tool to produce HTML pages, the core of the web.

I heard at a conference that at one point Yahoo wanted to standardize their development on one language. They reviewed 10 possible solutions and they ended up choosing PHP: the deal breaker was that capability of embedding PHP tags directly into the HTML.

The best tool for web development

So, as far as I am concerned, on the server-side PHP is just the best tool for web development (i.e. web page manufacturing).
Now, I would not use PHP for anything else. But for that one essential task, it is an outstanding tool.