首页 > php教程 > php手册 > 正文

PHP关于web页面交互内容

WBOY
发布: 2016-06-06 19:47:25
原创
1197 人浏览过

php中的常量定义 define() 定义形式:define("常量名","常量值",是否大小不写敏感(默认false)); 常量名:用大写字母和下划线组成; true:大小写不敏感; false:大小写敏感 事例代码如下: 1 ? php 2 3 define ("DEF_FIRST","first" ); 4 5 define ("DE

php中的常量定义  define()

定义形式:define("常量名","常量值",是否大小不写敏感(默认false));

常量名:用大写字母和下划线组成;

true:大小写不敏感;   false:大小写敏感

事例代码如下:

<span> 1</span> <span>php
</span><span> 2</span> 
<span> 3</span>      <span>define</span>("DEF_FIRST","first"<span>);
</span><span> 4</span> 
<span> 5</span>      <span>define</span>("DEF_SECOND","Second",<span>true</span><span>);
</span><span> 6</span> 
<span> 7</span>      <span>echo</span>   DEF_FIRST."<br>"<span>;
</span><span> 8</span> 
<span> 9</span>      <span>echo</span>   DEF_SECONd."<br>";<span>//</span><span>注意小写的d</span>
<span>10</span> 
<span>11</span>      <span>define</span>("DEF_FIRST","false");<span>//</span><span>这句话会报错</span>
<span>12</span> 
<span>13</span>      <span>echo</span>   DEF_FIRST."<br>"<span>; 
</span><span>14</span> 
<span>15</span> ?>
登录后复制

 

输出结果:

<span>1</span> <span>first
</span><span>2</span> <span>Second
</span><span>3</span> 
<span>4</span> Notice: <span>Constant</span> DEF_FIRST already <span>defined</span> in ****<span>on line11
</span><span>5</span> first
登录后复制

 

注:常量不允许重定义!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板