oop - PHP Autoloading Extended Classes -
based on response this question expect code work reason not. have simple class extends class library of classes.
_custom.php
$custom = new myclass(); class myclass extends myabstractclass{ public function __construct(){ parent::__construct(); } }
unfortunately fatal error:
fatal error: class 'myclass' not found in ...
but if remove extends myabstractclass
error goes away. seems issue when attempting extend class, not attempt load myabstactclass
causes myclass
not found @ all.
any thoughts or suggestions on this?
php interpreted language, meaning known php define code parsed before statement.
class myclass extends myabstractclass{ public function __construct(){ parent::__construct(); #you forcing construct call, not required if parent constructor has no args. } } $custom = new myclass();
with classes can prevent behavior using autoloader, when object called , undefined, try inject , parse class given code.
you can define magic function __autoload() spl_autoload_register() preferred more dynamic , not constant __autoload()
function is.
Comments
Post a Comment