Mega Code Archive

 
Categories / Php / Class
 

Using Class Constants in PHP5

<?php      class MyExample {           private $myvar;           public $readme;           const MY_CONSTANT = 10;           public function showConstant() {                echo "The value is: ".MY_CONSTANT;           }      }      $inst = new MyExample;      $inst->showConstant();      echo "The value: ".ConstExample::MY_CONSTANT; ?>