Archives
- Newer posts
- November 2024
- April 2024
- November 2023
- October 2023
- August 2023
- May 2023
- February 2023
- October 2022
- August 2022
- July 2022
- May 2022
- April 2022
- March 2022
- February 2022
- June 2020
- March 2020
- February 2020
- January 2020
- December 2019
- November 2019
- October 2019
- September 2019
- August 2019
- July 2019
- June 2019
- May 2019
- April 2019
- March 2019
- February 2019
- January 2019
- December 2018
- November 2018
- October 2018
- September 2018
- August 2018
- July 2018
- June 2018
- May 2018
- April 2018
- March 2018
- February 2018
- January 2018
- December 2017
- November 2017
- October 2017
- September 2017
- August 2017
- July 2017
- June 2017
- May 2017
- April 2017
- March 2017
- February 2017
- January 2017
- August 2016
- June 2016
- April 2016
- March 2016
- February 2016
- January 2016
- July 2015
- June 2015
- Older posts
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.
- 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.
- 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.
- 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.
- 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.