1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-08 07:46:46 +02:00

Add More Magic Methods in PHP

This commit is contained in:
Akshay Kalose
2015-10-16 22:07:08 -04:00
parent 0e6d9f6fe9
commit 64aa38a1d2

View File

@@ -503,6 +503,19 @@ class MyClass
{ {
} }
// Magic Methods
// what to do if Object is treated as a String
public function __toString() {
return $property;
}
// opposite to __construct()
// called when object no longer referenced
public function __destruct() {
print "Destroying"
}
/* /*
* Declaring class properties or methods as static makes them accessible without * Declaring class properties or methods as static makes them accessible without
* needing an instantiation of the class. A property declared as static can not * needing an instantiation of the class. A property declared as static can not