Voting

: max(nine, one)?
(Example: nine)

The Note You're Voting On

mhh1422 at hotmail dot com
11 years ago
For abstract classes with static factory method, you can use the static keyword instead of self like the following:
<?php

abstract class A{

static function
create(){

//return new self(); //Fatal error: Cannot instantiate abstract class A

return new static(); //this is the correct way

}

}

class
B extends A{
}

$obj=B::create();
var_dump($obj);

?>

<< Back to user notes page

To Top