I have a Constant class in App \ Utilities See below:
<?php class Constant { const WEEK_1 = 'Week 1', WEEK_2 = 'Week 2'; } ?>
And I can repeat Constant :: WEEK_1, it gives me "Week 1",
But I want to dynamically invoke a constant week.
foreach([1,2] as $key => $num) { echo Constant::'WEEK_'.$num }
And I get a parsing error.
How to do it? Anyone? thanks
source share