Using Class Constants in PHP5 : const « Class « PHP
- PHP
- Class
- const
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;
?>
Related examples in the same category