如何更改PHP常量? [英] How can I change PHP constants?

查看:83
本文介绍了如何更改PHP常量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用PHP手工制作自己的自定义CMS,并且已经定义了一些常量。有没有简单的方法可以修改常量?

I am working on making my own custom CMS in PHP by hand and I have a few constants I have defined. Is there an easy way to modify the constants?

我正在考虑使用 fopen()之类的东西,然后更改它,但我从未使用过文件系统功能。

I was thinking about using something like fopen() and then changing it, but I have never used the filesystem functions.

推荐答案


常量是标识符(名称)的简单值。 正如
的名称所暗示的,该值在脚本执行期间无法更改
。(
除外,魔术常数实际上不是常数)。
常量默认情况下区分大小写。按照惯例,常量
标识符始终是大写。

A constant is an identifier (name) for a simple value. As the name suggests, that value cannot change during the execution of the script (except for magic constants, which aren't actually constants). A constant is case-sensitive by default. By convention, constant identifiers are always uppercase.

常量的名称与PHP中的任何标签均遵循相同的规则。
有效常数名称以字母或下划线开头,后跟
个任意数量的字母,数字或下划线。作为常规的
表达式,将这样表示:
[a-zA-Z_\x7f-\xff] [a-zA-Z0-9_\x7f-\xff] *

The name of a constant follows the same rules as any label in PHP. A valid constant name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thusly: [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*

来自: 常量 (PHP专家)

From: Constants (PHP mamual)

这篇关于如何更改PHP常量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆