Vote Up 0 Vote Down

php use class constants

How to declare constants inside class in php ?
flag

Answers


Vote Up 0 Vote Down
You can define class constants in php like below :

<?php
class MyClass
{
const constant = 'constant value';

function showConstant() {
echo self::constant . "\n";
}
}

echo MyClass::constant . "\n";
flag | link |

Your Answer

Login before answering

Login with facebook