易截截图软件、单文件、免安装、纯绿色、仅160KB

php define() 函数及defined()函数的用法


The define() function defines a constant.
define()函数的作用是:定义一个常量。
Constants are much like variables, except for the following differences: 
常量[constant]与变量[variable]有很多相似的地方,因此,很容易混淆;下面,我们列举一下常量[constant]与变量[variable]之间的不同点:
A constant's value cannot be changed after it is set 
一个常量值在指定之后就不可以更改;
Constant names do not need a leading dollar sign ($) 
设置常量时,不需要在前面加上“$”符号;
Constants can be accessed regardless of scope 
常量可以被所有范围的域访问;
Constant values can only be strings and numbers 
常量的值只能是“字符串[string]”和“数字[number]”;
Syntax
语法
define(name,value,case_insensitive)
 
Parameter
参数Description
描述
name
Required. Specifies the name of the constant
必要参数。指定常量的名称
value
Required. Specifies the value of the constant
必要参数。指定常量的值
case_insensitive
Optional. Specifies whether the constant name should be case-insensitive. If set to TRUE, the constant will be case-insensitive. Default is FALSE (case-sensitive)
可选参数。指定常量的名称是否是不区分大小写的[case-insensitive]。如果设置为True,则不区分字母大小写;如果设置为False,则区分字母大小写。默认值是:False
Example 1
案例1
Define a case-sensitive constant:
指定一个常量(区分大小写):
<?phpdefine("GREETING","Hello you! How are you today?");echo constant("GREETING");?>
The output of the code above will be:
上述代码将输出下面的结果:
Hello you! How are you today?
Example 2
案例2
Define a case-insensitive constant:
指定一个常量(不区分大小写):
<?phpdefine("GREETING","Hello you! How are you today?",TRUE);echo constant("greeting");?>
The output of the code above will be:
上述代码将输出下面的结果:
Hello you! How are you today?
The defined() function checks whether a constant exists.
defined()函数的作用是:检查一个常量是否存在。
Returns TRUE if the constant exists, or FALSE


相关文档:

用php对json字符串编码问题

    昨天调用同事的一个json接口,发现调用php中的函数json_decode无法转化为数组。
   <?php
$json = "{'d':[['xxx','中国','广西','xjr7670@sina.com','2010-05-01 13:35:02'],['xxx','中国','广西','xjr7670@sina.com','2010-05-01 13:35:02']],'c':13659,'n':759}";
print_r( ......

Windows XP下简单配置本机PHP调试环境


作为实现动态网站的工具之一,PHP以其语法简单、高效快速和对数据库的广泛支持而深受用户欢迎。编写PHP程序和ASP一样需要在本机调试,为此需要配置一下调试环境。
有很多方案可以选择,这里提供两种较为简易的方法。
不管是哪种方法,都需要安装PHP。如果你是PHP使用者,你可能在网上找过PHP的安装资讯,它们几乎都说的 ......

PHP Array实用函数参考

array_flip
交换数组中的键和值
$arr1 = array('a'=>1,'b'=>2,'c'=>3,'d'=>4);
$array = array_flip($arr1);
showArr($array);
/*
Array
(
[1] => a
[2] => b
[3] => c
[4] => d
)
*/
array_key_exists
 
检查给定的键名或索引是否存在于数组中(也可用于对象 ......

PCNTL函数族 PHP多进程编程

php有一组进程控制函数,使得php能在*nix系统中实现跟c一样的创建子进程、使用exec函数执行程序、处理信号等功能。
引用
Process Control support in PHP implements the Unix style of process creation, program execution, signal handling and process termination. Process Control should not be enabled within a ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号