二者都是定义常量,有什么区别呢?缓存
const CONSTANT = 'aa'
在PHP5.3.0之后,能够使用const关键字在类定义以外定义常量。函数
使用const关键字定义常量必须处于最顶端的做用区域,由于用此方法是在编译时定义的。这就意味着不能在函数内,循环内以及if语句以内用const来定义常量。code
define (string $name, mixed $value, [bool $case_insensitive=false]) :bool
在运行时定义一个常量,在PHP5中value必须是标量,在PHP7中还容许是个array的值。string
$case_insensitive若是设置为true,该常量则大小写不敏感。it
大小写不敏感的常量以小写的方式储存。编译
Note: 编译是指PHP语言通过zend引擎编译成opcode,opcode能够经过apc等方式缓存;