24 Oct 2017
My Journey from Java to PHP

My Journey from Java to PHP

I joined OPSPL  on 1st September 2017. Previously, I worked as a full stack web developer at a Publishing Company in Madgaon, Goa. There I coded only in Java language and I did not have any skills in PHP. I got curious and started learning PHP this January.

I find PHP better than Java for the following reasons:

The overall cost associated to host apps developed in PHP is less than that to host the same apps developed in Java.

  1. In order to get tasks done, you have to write less code in PHP than that in Java. For example to print something in Java, you have to enter the command System.out.println(); but in PHP you can simply do it using echo or print statements.
  2. In PHP, you can develop apps faster, as there are many CMS like WordPress, Drupal, Magento, etc that saves development, maintenance and deployment time.

I learnt PHP from its documentation (php.net). PHP is very similar to Java and so the learning curve was not very steep for me.

However, I did notice the following differences between them:

Unlike Java, you don’t need to declare variable types when declaring variables. You can create $integer variable and assign string value to it. Well, this is not good since the developer can create a variable and reuse that same variable for different data types and thus create complex and difficult to understand code.

  1. In Java, there is Map interface that stores data using key and value pairs. However, in PHP there are associative arrays that have string as well as integer indexes. I find associative arrays simple than map interface because you have to define arrays and assign values to it and forget. Secondly, data in associative arrays will always be ordered. In Java, you have to remember various implementations of map interface (hashmap and treemap). Also, data in hashmap is not ordered.
  2. Like Java, PHP also has constructors. But the difference is that in Java, constructors have class names, whereas in PHP, you have to compulsorily use __construct for constructors. Secondly, Java class may have multiple constructors but  PHP class only has one constructor at a time. So if a developer does changes to his PHP code, he can easily change one constructor rather than changing multiple constructors in Java. (not sure about this point)

After gaining some PHP knowledge, I did small projects like Student Management System (with basic CRUD operations), email sending app and simple blogging system. In OPSPL, I now work on CakePHP projects. My future plans are to learn other frameworks like Codeigniter and Laravel and also CMS like WordPress and Magento.

So, to anyone who wants to learn PHP, I would tell them that PHP is a very easy language to learn. First, thoroughly go through the official documentation of PHP (php.net) and follow the examples given there. If you get stuck, just search for solutions and ideas on the Internet and do more projects to gain more experience.

Savio Menezes

Post Comments

* marked fields are mandatory.