Private Protected Php Code Example


Example: how to access private and protected members in php

<?php  class GrandPa {     protected $name = 'Mark Henry'; }  class Daddy extends GrandPa {     function displayGrandPaName()     {         return $this->name;     }  }  $daddy = new Daddy; echo $daddy->displayGrandPaName(); // Prints 'Mark Henry'  $outsiderWantstoKnowGrandpasName = new GrandPa; echo $outsiderWantstoKnowGrandpasName->name; // Results in a Fatal Error

Comments

Popular posts from this blog

Chemistry - Bond Angles In NH3 And NCl3

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Change The Font Size Of Visual Studio Solution Explorer