Double colon (::) this is used to access the static,constant and overridden properties or methods of a class.
Example1
——–
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<?php class mydoubts{ const mydoubts_val='mydoubts.in'; } $classname='mydoubts'; echo $classname::mydoubts_val; echo mydoubts::mydoubts_val; ?> |
self,parent and static are used to access the value inside the class
Example2
——–
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?php Class Vasanthan extends mydoubts { public static $inside_val='hello vasanthan'; public static function innerdisplay() { echo parent::mydoubts_val; echo self::$inside_val; } $classname='Vasanthan'; echo $classname::innerdisplay(); Vasanthan::innerdisplay(); } ?> |