Using the static modifier to change a member or method so it is accessible without instantiating the class : static variables « Language Basics « PHP






Using the static modifier to change a member or method so it is accessible without instantiating the class

 
<?php 
class myclass { 

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

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








Related examples in the same category

1.A static variable remembering its last value
2.Using the static Statement to Remember the Value of a Variable Between Function Calls
3.static variables
4.Working with Static Variables in Functions