php - 更改先前定义的常量的值

标签 php constants

我在 PHP 中定义了一个常量,例如

define('CONSTANT_NAME', 'constant_value');

我希望稍后能够在代码中更改此常量的值。

这可以吗?如果有,怎么做?

最佳答案

来自 http://php.net/manual/en/function.define.php (重点是我的):

define — Defines a named constant

来自 http://www.php.net/manual/en/language.constants.php :

As the name suggests, that value cannot change during the execution of the script

关于php - 更改先前定义的常量的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8481869/

相关文章:

java - 声明为内部类时 switch 语句中枚举值的行为

php - 重定向后 session 丢失

php - 如何更改Mysql查询(GROUP BY)错误sql_mode=only_full

php - 错误 [RuntimeException] 无法扫描 "database/seeds"内的类

c++ - 为什么 constexpr 是类型的一部分?

mysql - mysql 中 ref 的两个常量不应该是一个类型常量吗?

PHP,错误 1136 : Column count doesn't match value count at row 1

php - 关于 PHP 配置 :--with-zlib=DIR and --with-zlib-dir=DIR

c - 将参数传递给具有 const 参数的函数 : is it faster?

c++ - 将没有定义的 static const int 的地址传递给模板是否合法?