How to Unset Class in PHP
Calling a class allows a PHP Web developer to access methods and properties from a set of code (object) that has been pre-written. This prevents the developer from having to re-invent the wheel and write new code. A class also provides him with the luxury of re-using the same set of code for multiple applications. When the developer has finished using the class, he can deploy the "PHP unset()" function to unset the class from its containing variable.
Instructions
-
-
1
Assign the class to a variable. In this example the variable "my_class" will contain a new instance of the "myClass" class:
$my_class = new myClass;
-
2
Use the class. Consider this example, the "db_open" method has been called from the "myClass" class:
$my_class ->db_open();
-
-
3
Unset the class using the "unset()" function to clear the class from the "$my_class" variable:
unset($my_class);
-
1
References
- Photo Credit Comstock/Comstock/Getty Images