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 best credit cards

    You know I do like PHP and I don’t want it to become Java too. Nowadays you should clearly know what do you want to realize thereafter you easily can do it in PHP.

Comment pages
1 3 4 5 3240
Comments are open for an year period. Please, write here on Facebook page.