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
注:常量不允许重定义!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.