Do you know by any chance how could I access a global constant from a class?
for example:
Code: Select all
<?php
define('MY_CONSTANT', 'Hello World');
// MY_CONSTANT will be accessible from any function but not from classes, why? How can I solve this?
function myFunction()
{
echo MY_CONSTANT; // print "Hello World"
}
class myClass
{
const MY_CLASS_CONSTANT = "Grrrrr";
public function __construct()
{
echo MY_CONSTANT; // error...
echo MY_CLASS_CONSTANT; // print "Grrrrr"
}
}
?>
How can I access MY_CONSTANT without passing it to the constructor with something like myClass(MY_CONSTANT);........ ??
Thanks a lot