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!


<?php
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;
echo PHP_VERSION;

Output:
derived class
5.3.1

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.

Update:
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 PHPdeveloper.org has mentioned this post.

Update:
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 henk

    About your remark that Java copied C++… actually it mostly copied the behavior and feel of Objective-C. The syntax for defining a class, class members and calling those is C++, but the behavior is much more like Objective-C.

  • # 2 - by Matt

    @Thomas
    I think posting about this is fine as long as you don’t name the interviewer or his company. If the interviewer reads this, great. It’s an opportunity to learn from his mistakes.

    Speaking as someone who has interviewed a lot of developers over the years, you need to walk into technical interviews knowing the material inside and out. There’s no excuse for not knowing the answers to the questions you ask. If you’re not sure, don’t ask.

    A good developer will spot an incompetent interviewer very quickly.

  • # 3 - by foo

    super(); ?

  • # 4 - by Monika

    I completely agree with the fact that if you don’t know the answer don’t ask question. I take interviews for my company and before taking any interview I make sure that I know all the concepts before asking any question to candidate.

    What Satya mentioned is very common, because many big companies don’t have expertise people in LAMP. So if anyone from JAVA or Microsoft platform takes interview he/she compares and expects all the answers with his technology area.

    Anyway Satya don’t mind all this,, may be you deserve a better place 🙂
    also send your profile to my email id.

    • # 5 - by Satya Prakash

      Actually I know how things works here. but my only irritation is why they cannot listen me when I was putting my points forwards and telling them convincingly.

  • # 6 - by Artur Ejsmont

    Hehehe good man, that has to be a crappy place to work if people in charge for technical interview do not even know their answers. Well …. it still could work if they would not insist on their version 🙂

    chin up, im sure there are better places than this one.

    Cheers

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