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;
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.