PHP is not Java

I went for an Interview and there interviewer asked me few questions. I disagreed on two questions and their answers. According to interviewer, it is must to use parenthesis while initializing class( new className()), but I said if it requires parameters then it is essential otherwise it is not. After I disagreed they said it is essential in new PHP version 5.2.x. Still I disagreed then he said, no no after PHP 5.2.x, PHP is like Java.
Second question was about constructors. I said parent constructor will not be called when I initialize derived class that has its own constructor. He answered that no it will called. I said, it is in Java and not in PHP. So, again he said, PHP has everything now and it is like Java. I like PHP and I do not want it to become Java. If just by implementing Object Oriented Programming, it can be said, PHP is following Java then I will say Java is following C++ or Java copied C++.

Because he denied so convincingly that my answer is wrong according to new changes in PHP, so I thought to check myself. I found my answer was correct.

Now, if he remember and show the courage to correct himself and accept his mistake then at least these two questions will not be the criteria for not selecting me!

class base {
	public function __construct() {
		echo '<p>base class</p>';
class derived extends base {
	public function __construct() {
		echo '<p>derived class</p>';
$obj1 = new derived;

derived class

Except, echo statement content, this was the code I have written there.

Above, I have not used parenthesis at the time of initialization and parent class constructor has not called automatically when I initialize derived class. and my PHP version is 5.3.1.

One may think how these kind of questions come for discussion.
Actually the question they asked was to create a base class and a derived class. and write echo statements in constructors. So, I have written that on paper. After seeing my code he got two questions and that is what I have written above. One bad point is I never been a part of greenfield project based on complete Object oriented implementation.
In few days, it will be confirmed about my selection there. If they did not select me then I will disclose the company name here to add more spice to this post.
I am inspired to know that has mentioned this post.

Ok. I am not mentioning the company name and Interviewer name but those who know can understand a little when I say that company is a IT development center or complete development center (I mean they may be taking outside work as well) for an University. It is situated in Ashwini Layout, Koramangala, Bangalore.
I did not like them because they have not introduced themselves (2 interviewer were there) and only asked few questions. and Not selected me (too bad :)).

  • # 1 - by Gobi

    Hey Satya,

    Thanxs for sharing ur experience … well people thinking that they are geek & they are the only person here known everything 🙂 . But they are good in talking , We are the people who work with coding all days all time . I’m damn sure we are geeks not them ….

    Have fun coding 🙂

  • # 2 - by mario

    It’s not just the interviewer. This is a common issue. Many developers also try to treat or bend PHP into something like Java. Because PHP is often perceived as inferior language, this is unconsciously compensated with synactic salt and semantic constructs from other environments. This is commonly called “cargo cult programming”. (Another example would be the access modifiers public/private/proctected, which only add hypothetical benefits but add a security appearance to your code.)

    Anyway, it’s important to GET OVER IT. It is an issue in PHP, and you won’t find a company without it. Embrace questionable coding methodologies to fit in, and perform language education cannily.

  • # 3 - by Satya Prakash

    “cargo cult programming” a new terms for me.
    For comment about “access modifiers public/private/proctected”, it is debatable. I feel we need to for allowing or not allowing to modify it and how we need to access it as well. Not just for security reason.

  • # 4 - by Thiago Belem

    Facepalm to them! Maybe it’s better look for job on another company.. Or you’ll need to use their PHP-Java version. 😛

Comment pages
Comments are open for an year period. Please, write here on Facebook page.