abstract:?php header("Content-type: text/html; charset=utf-8");//函数define('FACTION','古墓派');//关键字const USER_NAME = '杨过';//2,访问echo FACTION,'的大弟子:',USER_NAME, '
?php
header("Content-type: text/html; charset=utf-8");
//函数
define('FACTION','古墓派');
//关键字
const USER_NAME = '杨过';
//2,访问
echo FACTION,'的大弟子:',USER_NAME, '<br>';
//常量的本质就是一个只读变量;
//3,常量作用域
function demo(){
return '我是'.FACTION.'的二当家的:'.USER_NAME.'<br>';
}
echo demo();
//4,define() 和 const 的区别
$price = 99;
define('BOOK', $price);
echo BOOK,'<br>';
//comst的常量值只允许简单变量(标准变量:整数,浮点,布尔,字符串,必须是字面量)
// const BOOK = 'php从入门到精通';
echo BOOK,'<br>';
//const可以声明类常量
class Test1{
// define('NAME','PETER ZHU');
const NAME = 'peter zhu';
}
echo Test1::NAME;
Correcting teacher:查无此人Correction time:2019-05-17 09:42:36
Teacher's summary:完成的不错。常量不会变,一般保存域名或路径,一单确定,不会变动的。继续加油。