Blogger Information
Blog 87
fans 0
comment 0
visits 59362
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
第三章:2.常量的声明,赋值与输出
黄忠倚的博客
Original
520 people have browsed it

实例

<?php
echo '<h2>2.常量的声明,赋值与输出</h2>';
echo '<hr color="red">';

/医院
 *1.常量三要素:
 *	1.1一旦创建,不可修改,不可删除
 *	1.2不要在前面加$
 *	1.3全局作用域,在函数中可以直接使用,不需要用global
 *2.创建:define('CONST_NAME',value)	
 * 	推荐全部采用:大写字母,之间用下划线连接
 *
 *3.访问:echo ,print, constant(const_name) 
 *4.define(const_name)
 */
//创建常量
define('SITE_NAME','Kevin Wong的博客');
const COUNTRY = '中国'; //const
// 访问
echo SITE_NAME,COUNTRY;
echo '<hr>';
echo constant('SITE_NAME');
echo '<hr><pre>';
//获取当前系统中所有的常量,包括自定义
// print_r(get_defined_constants());

echo defined('SITE_NAME') ? '已经自定义过了' : '未定义';

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post