首頁  >  文章  >  php教程  >  PHP关于web页面交互内容

PHP关于web页面交互内容

WBOY
WBOY原創
2016-06-06 19:47:251191瀏覽

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

 

注:常量不允许重定义!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn