If the variable was defined as private static, it would not be possible to access it directly : private « Class « PHP






If the variable was defined as private static, it would not be possible to access it directly

 
<?php 
class myclass { 

    const MYCONST = 123; 
    private static $value = 567; 
} 

echo 'myclass::MYCONST = ' . myclass::MYCONST . "\n"; 
echo 'myclass::$value = ' . myclass::$value . "\n"; 
?>
  
  








Related examples in the same category

1.class member variable access: private
2.Access private properties with for each loop
3.Changing the member $a to protected or private
4.Using private and public in Classes
5.Private and inheritance
6.Private properties are accessible only inside the methods of the class that defined them
7.Protect the class from being misused by accessing the members directly