Here is part of my code
define('DIR_APP', 'app/'); class Questions { const QUESTIONS_FILE = DIR_APP . 'questions.xml'; }
Seems when I take the define()‘d constant out of my class constant declaration, it works fine. But when I add it it throws this error:
Parse error: syntax error, unexpected '.', expecting ',' or ';' in /home/public_html/app/classes/Questions.class.php on line 7
So how can I get my define()‘d constant in there? I assume it is not correctly looking up the DIR_APP thinking it might of been defined within the class. How do I get it to resolve it globally?
Thank you
It can’t be done.
Quote from http://www.php.net/manual/en/language.oop5.constants.php :
I think you could
but that is global.