我尝试通过循环定义常量值,但出现错误:
Notice: Use of undefined constant XXXXX - assumed 'XXXXX' in XX on line XX
这是代码:
$q = "SELECT `Key`, `Value` FROM appconfig";
//I skip the line to read from database
while($fetch = mysqli_fetch_array($r)) {
define("'" . $fetch["Key"] . "'", $fetch["Value"]);
//I try to echo $fetch["Key"] and $fetch["Value"] and it returns value
}
代码有问题吗?我试图手动定义它并且它有效。