Reputation: 13
I want to get the value of a constant "test" using "test1".
I have tried it but only getting "test1" value but not "test" value.
<?php
class test
{
const test='fast';
const test1=test;
function testing()
{
echo test::test1;
}
}
<?php
include_once('class.test.php');
$d=new test;
echo $d->testing();
?>
Any suggestions?
Upvotes: 0
Views: 104
Reputation:
Below is just a working solution, but you have to consider about lot of things such as naming conventions:
<?php
class test
{
const test='fast';
const test1=test;
function testing()
{
echo self::test1;
echo self::test1;
}
}
?>
<?php
include_once('class.test.php');
$d=new test;
echo $d->testing();
?>
Upvotes: 0