1 / 16
文档名称:

php手册笔记.doc

格式:doc   大小:49KB   页数:16页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

php手册笔记.doc

上传人:1314042**** 2020/12/31 文件大小:49 KB

下载得到文件列表

php手册笔记.doc

相关文档

文档介绍

文档介绍:2想得到一个易读懂的类型的表达方式用于调试,用 gettype()。
3查看某个类型,不要用 gettype(),而用 is_type 函数。
<?php
$a_bool = TRUE; // a boolean
$a_str = "foo"; // a string
$a_str2 = 'foo'; // a string
$an_int = 12; // an integer
echo gettype($a_bool); // prints out: boolean
echo gettype($a_str); // prints out: string
// If this is an integer, increment it by four
if (is_int($an_int)) {
$an_int += 4;
}
// If $bool is a string, print it out
// (does not print out anything)
if (is_string($a_bool)) {
echo "String: $a_bool";
}
?>
4要将一个变量强制转换为某类型,可以对其使用强制转换或者 settype() 函数。
5当转换为 boolean 时,以下值被认为是 FALSE:
■the 布尔值 FALSE 自身
■the 整型值 0 (零)
■the 浮点型值 00 (零)
■空 字符串, 以及 字符串 "0"
■不包括任何元素的数组
■不包括任何成员变量的对象(仅PHP 40 适用)
■特殊类型 NULL (包括尚未设定的变量)
■从没有任何标记(tags)的XML文档生成的SimpleXML 对象
所有其它值都被认为是 TRUE(包括任何资源)。
6Warning
如果向八进制数传递了一个非法数字(即 8 或 9),则后面其余数字会被忽略。
Example #2 八进制数的怪事
<?php
var_dump(01090); // 八进制 010 = 十进制 8
?>
7整数溢出
如果给定的一个数超出了 integer 的范围,将会被解释为 float。同样如果执行的运算结果超出了 integer 范围,也会返回 float。
8array( key => value
,
)
// 键(key) 可是是一个 整数(integer) 或 字符串(string)
// 值(value) 可以是任意类型的值<?php
$arr = array("foo" => "bar", 12 => true);
echo $arr["foo"]; // bar
echo $arr[12]; // 1
?>
key 可以是 integer 或者 string。如果key是一个 integer 的标准表示,则被解释为整数(例如 "8" 将被解释为 8,而 "08" 将被解释为 "08")。key 中的浮点数被取整为 integer。在 PHP 中索引数组与关联 数组 是相同的,它们都可以同时包含 整型 和 字符串 的下标。
9要删除一个键名/值对,要对它用 unset()。
<?php
$arr = array(5 => 1, 12 => 2);
$arr[] = 56; // This is the same as $arr[13] = 56;
// at this point of the script
$arr["x"] = 42; // This adds a new element to
// the array with key "x"

unset($arr[5]); // This removes the element from the array
unset($arr); // This deletes the whole array
?>
10在下列情况下一个变量被认为是 NULL:
■被赋值为 NULL。
■尚未被赋值。
■被 unset()。
NULL 类型只有一个值,就是大小写不敏感的关键字 NULL(你可以写成NULL,也可以写成null)。
11Callback 函数不仅可以是一个简单的函数,它还可以是一个对象的方法,包括

最近更新