php中define和const 的区别
来源:互联网 发布:淘宝网店提升信誉 编辑:程序博客网 时间:2024/06/06 03:59
常量是一个简单的标识符。在脚本执行期间该值不能改变(除了所谓的魔术常量,他们其实不是常量)。常量默认大小写敏感。通常常量标识符总是大写的。可以简单的通过指定其名字来获得常量的值,与变量不同,不应该在常量的前面加上$符号。常量可以不用理会变量的作用域在任何地方定义和访问.
在php中定义常量时,const和define的区别?
1、const可用于类成员变量的定义,一经定义,不可修改。Define不可以用于类成员变量的定义,可用于全局常量。
2.const采用普通的常量名称,define可以采用表达式作为名称
<?php const FOO = 'BAR'; for ($i = 0; $i < 32; ++$i) { define('BIT_' . $i, 1 << $i); }?>
3.const只能接受静态的标量,而define可以采用任何表达式
<?phpconst BIT_5 = 1+1 // 无效的invaliddefine('BIT_5', 1+1); // 有效的valid?>
阅读全文
1 0
- php中const和define的区别
- php中define和const 的区别
- php中static、const和define的区别
- PHP中const和define()定义常量的细节区别
- PHP中const和define()定义常量的细节区别
- php中static、const和define的区别
- PHP中const和define()定义常量的细节区别
- PHP中const和define()定义常量的细节区别
- PHP中const和define()定义常量的细节区别
- php中const与define的区别
- PHP中const与define的区别
- PHP中const与define的区别
- PHP:const和define的区别
- php const和define的区别
- php const和define的区别
- C++ 中 const和define的区别
- php const和define的区别(php类中如何定义常量)
- php const和define的区别(php类中如何定义常量)
- sound函数及大调音阶播放
- Android LayoutInflater详解
- Micro Services
- 浅谈二叉树
- AndroidStudio的翻译插件ECTranslation
- php中define和const 的区别
- display is not Valid解决办法
- java 开发 jni
- 计算机网络相关知识
- 初识BottomBar
- 关于解决cv2.findContours返回值too many values to unpack (expected 2)的问题
- JSON数据格式以及GSON的使用
- 反射
- 第3章 随机变量的数字特征