PHP | class_alias() Function Last Updated : 16 Apr, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The class_alias() function is an inbuilt function in PHP which is used to create an alias name of the class. The functionality of the aliased class is similar to the original class. Syntax: bool class_alias( string $original, string $alias, bool $autoload = TRUE ) Parameters: This function accepts three parameters as mentioned above and described below: $original: This parameter holds the original class name. $alias: This parameter holds the alias class name. $autoload: It is autoload or not if original class is not found. Return Value: It returns Boolean value i.e. either True on success or False on failure. Below programs illustrate the class_alias() function in PHP: Program 1: php <?php // Create a class class GFG { public $Geek_name = "Welcome to GeeksforGeeks"; // Constructor is being implemented. public function __construct($Geek_name) { $this->Geek_name = $Geek_name; } } // Create the class name alias class_alias('GFG', 'GeeksforGeeks'); // Create an object $Geek = new GeeksforGeeks("GeeksforGeeks"); // Display result echo $Geek->Geek_name; ?> Output: GeeksforGeeks Program 2: php <?php // Creating class class GFG { public $data1; public $data2; public $data3; } // Create the class name alias class_alias('GFG', 'Geeks'); // Creating an object $obj1 = new GFG(); $obj2 = new Geeks(); var_dump($obj1 === $obj2); // Set values of $obj object $obj2->data1 = "Geeks"; $obj2->data2 = "for"; $obj2->data3 = "Geeks"; // Print values of $obj object echo "$obj2->data1 \n$obj2->data2 \n$obj2->data3"; ?> Output: bool(false) Geeks for Geeks Reference: https://www.php.net/manual/en/function.class-alias.php Comment More infoAdvertise with us Next Article PHP | get_called_class() Function A ashokjaiswal Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-OOP Similar Reads PHP | get_called_class() Function The get_called_class() function is an inbuilt function in PHP which is used to get the class name where the static method is called. Syntax: string get_called_class( void ) Parameters: This method does not accept any parameter. Return Value: This function returns the class name on success and return 1 min read PHP | get_class() Function The get_class() function is an inbuilt function in PHP which is used to return the class name of an object. Syntax: string get_class( object $object ) Parameters: This function accepts single parameter $object which holds the object that need to be tested. The value of this parameter can be omitted 1 min read PHP | class_exists() Function The class_exists() function is an inbuilt function in PHP which is used to check whether the given class is defined or not. Syntax: bool class_exists( string $class_name, bool $autoload = TRUE ) Parameters: This function accept two parameters as mentioned above and described below: $class_name: It h 2 min read PHP class_uses() Function The class_uses() function is an inbuilt function in PHP where the traits utilized by the given class, will be returned. Syntax: class_uses($object_or_class,$autoload = true): array|false Parameters: This function accepts the two parameters that are described below object_or_class: The name of the cl 2 min read PHP class_parents() Function The class_parents() function is an inbuilt function in PHP where the parent class for the given class will be returned. Syntax: class_parents( object|string $object_or_class, bool $autoload = true ): array|false Parameters: This function accepts two parameters that are described below: object_or_cla 1 min read PHP get_class_vars() Function The get_class_vars() function is an inbuilt function in PHP which is used to get the default properties of a class. Syntax: array get_class_vars(string $class)Parameters: This function accepts one parameter that is described below: $class: This parameter specifies the name of the class.Return Value: 1 min read Like