I have 1 php file called defines.php with the following definition:
Code: Select all
define("Age_Dog", 7);Code: Select all
define("Age_Cat", 3);Code: Select all
require_once(<path to file>/defines.php);I have a variable called $animal which indicates which constant is available. The value of the $animal variable is either 'Dog' or 'Cat'
I would like to define one variable called $animalAge which will hold the correct age depending on what file was included
I tried doing:
Code: Select all
eval('\$animalAge = "Age_"' . $animal );does anyone know how I can do this?
I am looking for a solution using eval (not if else and other conditionals)
regards