• Home
  • Technology
    • Ebullientech
    • Entrepreneurship
    • Video Technology
    • Cloud Computing
    • Business Analysis
  • Healthcare
    • Pharmacology
  • Thoughts
    • Food
    • General
    • Stories
    • Places
    • Workplace
    • Social Issues
    • Reviews
  • Quotes
  • Ebullientech News and Events
  • About

Kamalika's Notebook

thinking nothing...............!!

You are here: Home / Kamalika / Technology / PHP / PHP vs. Java which is a better Object Oriented Language?

PHP vs. Java which is a better Object Oriented Language?

February 9, 2015 By Kamalika Leave a Comment

Object-oriented programming

PHP 5 borrowed its object-oriented paradigm from Java, which is the standard implementation of an object-oriented language today. After the release of PHP 5, a key point in the introduction of a serious object paradigm, PHP is evolving towards OOP and has borrowed more from Java products: Doctrine 2 is an object-relational mapper inspired by Hibernate and JPA; phpDocumentor is built on the example of Javadoc; PHPUnit is one of the xUnit products, which derive from the original JUnit.

 

  • PHP classes do not have final fields, although what would be a static final field in Java is a const in PHP. EDIT: A const in PHP is more limited than a static final in Java as the latter can be an array or object instance, whereas the former must be a constant value (number or a string, essentially).
  • “Overloading” in PHP does not mean the same as it does in Java. In Java, it means specifying multiple methods of the same name, but with a different set of parameters: public void myMethod(int foo){}; public void myMethod(float foo){};
  • In PHP, it refers to the dynamic creation of properties and methods using the __get(), __set() and __callStatic() “magic” methods. See the PHP manual for a description on their use. Java-style method overloading is impossible in PHP and an attempt to re-declare a method (with or without a different set of parameters) will fail.
  • May be obvious to some, but in PHP you use :: to access static methods and properties and -> to access instance ones, but in Java . is used for both.
  • PHP doesn’t have packages, but it does have namespaces.
  • As of PHP5, constructors in PHP are not supposed to be methods with a name that matches the class, like in Java, but the magic method __construct() should be declared instead, although the PHP4 style is supported for backward-compatibility. Also, PHP has a destructor method named __destruct().
  • In Java, all classes inherit from Object, but there is no such generic super-class in PHP.
  • Even when maximizing the amount of OOP in a PHP script, it still relies on a procedural flow; there’s no class-level entry point like in Java (i.e., public static void main(String[] args) or public void init() for applets).

References:

Java vs. PHP

Stackoverflow

Pages: 1 2 3

Filed Under: PHP Tagged With: Java OOP, Java versus PHP, Object Oriented Programming, PHP OOP

« How to Find Only Unread Messages in Gmail
PHP and MVC Design Pattern »

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Connect with Facebook

Let’s connect…

  • Facebook
  • Instagram
  • LinkedIn
  • Twitter
  • YouTube

Hello There…

I'm Kamalika, a techpreneur & startup mentor, blogger, hobbyist photographer, Netflix & Kindle indulgent, food connoisseur, Starbucks aficionado and former Disney employee ...next

Looking for something?

Tags

All in One SEO Pack AWS Banaras Blogger Blogging Blogs Dasaswamedh Ghat Ebullientech Ebullientech Interactive LLP Facebook Facebook Developers father's day father's day wishes father's day wishes for dad fathers day love Fathers Day Special Fathers Day wishes from daughter Father’s day memories GeoTech GeoTech Informatics HipHop for PHP Kamalika Guha Roy Kashi Ganga LAMP MySQL Nabaneeta Guha Roy Online Marketing PayPal PayPal's suspension of Indian bank transactions PHP PHP & MySQL Saraswati Puja Search Engine Optimization SEO Startup The Ganges TypePad UCO HUT Varanasi Web 2.0 Web 2.0 Design Web Design Web Marketing WordPress WordPress.COM

Timeline

  • 2024 (1)
  • 2021 (3)
  • 2020 (7)
  • 2019 (4)
  • 2018 (1)
  • 2015 (6)
  • 2014 (13)
  • 2013 (9)
  • 2010 (7)
  • 2009 (2)

Topics

Copyright © 2021 · Kamalika Guha Roy, Powered by: Ebullientech