1. __toString() Magic method
The __toString() method is automatically called when an object is converted into a string for the purpose of display or concatenation
2. __get() and __set() Magic Method
__get() is used when value from an undefined variable is to be read and __set() is used when a value is to be assigned to a undefined variable of a class
3. __isset() and __unset() Magic Method
The magic method __isset() method receives an argument - the value of which is the name of the variable that the program wants to test if the variable is set or not. The magic method __unset() method receives an argument - the value of which is the name of the variable that the program wants to unset.
4. __call() Magic method
These methods are automatically called internally when the program tires to execute a method that has not been defined within the class at the time of development
5. __autoload() method
The magic method __autoload() function is a convenience that allows you to use classes without having to explicitly write code to include them The magic method __autoload() is not included in your class definition as this is to be called once in a script. The best place to put the autoload() file is in your configuration file which is loaded in all your other scripts
6. __sleep() and __wakeup()
The magic method __sleep() and __wakeup() is called when an object is serialized. The magic method __sleep() and __wakeup() provides a method to clean up and restore objects before being serialized.
__sleep() magic method is called when the object of a class is about to be serialized. This magic method __sleep() does not accept any parameter and returns an array. The array should contain a list of class members that should be serialized. This means that if you don’t wish to serialize a particular class member, you should not include it in the array.
__wakeup() magic method is the opposite of the __sleep() method. It is called when the object of a class is about to be unserialized. This magic method __wakeup() does not accept any parameter nor returns anything. The __wakeup() method is responsible for setup operations after an object has been unserialized
7. __clone() method
to create a new $obj2 object we must clone an object to create a new one. To clone an PHP5 Object a special keyword i.e. clone is used
The __toString() method is automatically called when an object is converted into a string for the purpose of display or concatenation
2. __get() and __set() Magic Method
__get() is used when value from an undefined variable is to be read and __set() is used when a value is to be assigned to a undefined variable of a class
3. __isset() and __unset() Magic Method
The magic method __isset() method receives an argument - the value of which is the name of the variable that the program wants to test if the variable is set or not. The magic method __unset() method receives an argument - the value of which is the name of the variable that the program wants to unset.
4. __call() Magic method
These methods are automatically called internally when the program tires to execute a method that has not been defined within the class at the time of development
5. __autoload() method
The magic method __autoload() function is a convenience that allows you to use classes without having to explicitly write code to include them The magic method __autoload() is not included in your class definition as this is to be called once in a script. The best place to put the autoload() file is in your configuration file which is loaded in all your other scripts
6. __sleep() and __wakeup()
The magic method __sleep() and __wakeup() is called when an object is serialized. The magic method __sleep() and __wakeup() provides a method to clean up and restore objects before being serialized.
__sleep() magic method is called when the object of a class is about to be serialized. This magic method __sleep() does not accept any parameter and returns an array. The array should contain a list of class members that should be serialized. This means that if you don’t wish to serialize a particular class member, you should not include it in the array.
__wakeup() magic method is the opposite of the __sleep() method. It is called when the object of a class is about to be unserialized. This magic method __wakeup() does not accept any parameter nor returns anything. The __wakeup() method is responsible for setup operations after an object has been unserialized
7. __clone() method
to create a new $obj2 object we must clone an object to create a new one. To clone an PHP5 Object a special keyword i.e. clone is used
No comments:
Post a Comment