mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
Merge pull request #1583 from AkshayKalose/patch-4
Add More Magic Methods in PHP
This commit is contained in:
commit
5d23c9ec27
@ -539,10 +539,23 @@ class MyClass
|
||||
print 'MyClass';
|
||||
}
|
||||
|
||||
//final keyword would make a function unoverridable
|
||||
// final keyword would make a function unoverridable
|
||||
final function youCannotOverrideMe()
|
||||
{
|
||||
}
|
||||
|
||||
// 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
|
||||
|
Loading…
Reference in New Issue
Block a user