Can you read out the name of a PHP constant from a database and use it inside of a php variable, to display the value of the constant for use in a menu?
For example here's what I'm trying to accomplish
In SQL: select menu_name AS php_CONSTANT where menu_id=1
the value returned would be L_HOME which is the name of a CONSTANT in a php config page. The php config page looks like this define('L_HOME','Home');
and gets loaded before the database call.
The php usage would be $db_returned_constant
which has a value of L_HOME
that came from the db call, then I would place this into a string such as $string = '<ul><li>' . $db_returned_constant . '</li></ul>'
and thus return a string that looks like $string = '<ul><li><a href="#" onclick="path_from_db">Home</a></li></ul>'
.
To sum up what I'm trying to do
- Load a config file based on the language preference
- query the db to return the menu name, which is the name of a CONSTANT in the config file loaded in step one, and also retrieve the menu_link which is used in the "onclick" event.
- Use a php variable to hold the name of the CONSTANT
- Place the variable into a string that gets echo'd out to create the menu displaying the value of the CONSTANT.
I hope this makes enough sense...is it even possible to use a constant like this?
Thanks.