I am currently programming a website (in PHP4). I plan on storing values ββthat do not change at run time in constants. This is, for example, the version number of the login data for the database.
Question 1: Are there any security problems that may arise as a result of storing data in constants?
Currently, to define and call a constant, I am doing the following:
define("VERSION", "1.0"); echo "Current version: ".VERSION."."; // Result: "Current version: 1.0."
One thing annoys me: if a constant is not defined, the "incorrect" variable name is returned instead. NULL
define("VERSION", "1.0"); echo "Current version: ".VERSIONXXX."."; // Result: "Current version: VERSIONXXX."
One of the solutions I found to get the error message, and the return value is "NULL" when I accidentally entered the wrong constant name, uses the constant() function:
define("VERSION", "1.0"); echo "Current version: ".constant("VERSIONXXX")."."; // Result: "Current version: ."
Question 2: Can I prevent another way that PHP returns the name of a nonexistent variable?
Question 3: If a constant value in PHP is always returned using the constant() function?
R_User
source share