mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-06 23:06:49 +02:00
Merge pull request #1583 from AkshayKalose/patch-4
Add More Magic Methods in PHP
This commit is contained in:
@@ -544,6 +544,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 is 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
|
||||||
|
Reference in New Issue
Block a user