PHP | class_alias() Function Last Updated : 16 Apr, 2020 Comments Improve Suggest changes 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 Create Quiz Comment A ashokjaiswal Follow 0 Improve A ashokjaiswal Follow 0 Improve Article Tags : Web Technologies PHP PHP-function PHP-OOP Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like