Thursday, March 10, 2011

a difference i didn't expect between php 5.2 & php 5.3 (overriding abstract function)

Here is my code:

abstract class App_Daos_Abstract
{
abstract public function buildModel($result);
}

class UserDao extends App_Daos_Abstract
{
public function buildModel($result = null)
{
}
}

If i run this code on php 5.2.14 + windows, i will get "Fatal error: Declaration of news::buildModel() must be compatible with that of App_Daos_Abstract::buildModel()".

However, if i run the code on php 5.3 + ubuntu, everything is fine.

I don't think windows or ubuntu matter. I think this is a difference between PHP 5.2 and PHP 5.3. So even at this point PHP 5.3 is more closer to JAVA.

1 comment:

Muhammad Azeem said...

This is a nice article..
Its very easy to understand ..
And this article is using to learn something about it..
c#, dot.net, php tutorial
Thanks a lot..!