Domanda

On the docs page on class_alias function we read:

class_alias — Creates an alias for a class

bool class_alias ( string $original , string $alias [, bool $autoload = TRUE ] )

Creates an alias named alias based on the user defined class original. The aliased class is exactly the same as the original class.

Parameters

original

The original class.

alias

The alias name for the class.

autoload

Whether do autoload if the original class is not found.

Well, so under what condition the class that's being aliased is autoloaded? When $autoload is set to true? Ok, but why the description of this parameter says that autoloading is to take place "if the original class is not found"? How can PHP autoload a class it can't find?

È stato utile?

Soluzione

The better way to put it would be:

Whether to autoload if the original class is not loaded.

That means, if the class definition is currently not known, because its file has not been included. That's when a class is "not found". In that case class_alias can invoke the registered autoloaders which will (hopefully) automatically include the file where the class is defined.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top