The usage of the class alias in php5.3. In PHP5.3, if you want to introduce some classes with a long name, it will be difficult to write. in this case, you can use the class alias of PHP5.3, for example: classIrrational_Long in PHP 5.3, if you want to introduce some classes with a long name, it will be difficult to write. at this time
You can use the alias of PHP 5.3 class, for example:
Class Irrational_Long_Class_Name
{
// Empty class
}
Class_alias (Irrational_Long_Class_Name, ShortAlias );
$ ShortAliasInstance = new ShortAlias ();
Var_dump ($ shortAliasInstance instanceof Irrational_Long_Class_Name );
# True
Var_dump ($ shortAliasInstance instanceof ShortAlias );
# True
You can use get_class () to obtain the original real class name, for example:
Class Irrational_Long_Class_Name
{
Public function getClass ()
{
Print get_class ();
}
}
Class_alias (Irrational_Long_Class_Name, ShortAlias );
$ AInstanceWithAlias = new ShortAlias ();
$ AInstanceWithAlias-> getClass ();
# Irrational_Long_Class_Name
Print get_class ($ aInstanceWithAlias );
# Irrational_Long_Class_Name
You can also directly use the alias class in the FUNCTION, for example:
Class TestClass
{
Public function doSomethingWithShortAliasInstance (ShortAlias $ B ){}
}
Class_alias (Irrational_Long_Class_Name, ShortAlias );
$ AInstanceWithAlias = new ShortAlias ();
$ TestClassInstance = new TestClass ();
$ TestClassInstance-> doSomethingWithShortAliasInstance ($ aInstanceWithAlias );
In example 5.3, if you want to introduce some classes whose names are long enough, it will be difficult to write them. in this case, you can use the class alias of PHP 5.3, for example: class Irrational_Long...