View
110
Download
1
Tags:
Embed Size (px)
Citation preview
Maneesha K K
www.facebook.com/username
twitter.com/username
in.linkedin.com/in/profilename
7559813984
MAGIC METHODS IN PHP
Disclaimer: This presentation is prepared by trainees ofbaabtra as a part of mentoring program. This is not officialdocument of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
What is a MAGIC METHOD ??
•A special method ,starting with __.
• Methods which will be triggered in response toparticular PHP events.
Some Examples for Magic Methods__construct()__destruct()__get()__set()__isset()__unset()
__construct
A method that gets called when the object is instantiatedEg :
<?phpclass Books
{public function __construct(){echo "Using the magic method...<br />";}}
$physics = new Books;?>
__destruct
It gets run when all the reference to an object is removed.Object is explicitly destroyed.This method is called even if the script exits due to a call to exit()
EG ::<?phpclass Books{function __destruct(){
echo "This object is no longer needed..";}}$a=new Books();unset($a);?>
__get•This method called when your object attempt to read property or variable of the class which is inaccessible or unavailable.
__set•When object of your class attempts to set value of the property which isreally inaccessible or unavailable in your class.
__isset•It will trigger when isset() function is applied on any property of the classwhich is inaccessible or unavailable.
__unset•It is something opposite of isset method. •This method called when unset() function called on inaccessible •or unavailable property of the class.
Want to learn more about programming or Looking to become a good programmer?
Are you wasting time on searching so many contents online?
Do you want to learn things quickly?
Tired of spending huge amount of money to become a Software professional?
Do an online course @ baabtra.com
We put industry standards to practice. Our structured, activity based courses are so designedto make a quick, good software professional out of anybody who holds a passion for coding.
Follow us @ twitter.com/baabtra
Like us @ facebook.com/baabtra
Subscribe to us @ youtube.com/baabtra
Become a follower @ slideshare.net/BaabtraMentoringPartner
Connect to us @ in.linkedin.com/in/baabtra
Give a feedback @ massbaab.com/baabtra
Thanks in advance
www.baabtra.com | www.massbaab.com |www.baabte.com
Emarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550
NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550
Cafit Square,Hilite Business Park,Near Pantheerankavu,Kozhikode
Start up VillageEranakulam,Kerala, India.
Email: [email protected]
Contact Us