1 / 16
文档名称:

php手册笔记.doc

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

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

分享

预览

php手册笔记.doc

上传人:文库旗舰店 2018/8/25 文件大小:87 KB

下载得到文件列表

php手册笔记.doc

相关文档

文档介绍

文档介绍:,用var_dump()。,用gettype()。,不要用gettype(),而用is_type函数。<?php$a_bool=TRUE;//aboolean$a_str="foo";//astring$a_str2='foo';//astring$an_int=12;//anintegerechogettype($a_bool);//printsout:booleanechogettype($a_str);//printsout:string//Ifthisisaninteger,incrementitbyfourif(is_int($an_int)){$an_int+=4;}//If$boolisastring,printitout//(doesnotprintoutanything)if(is_string($a_bool)){echo"String:$a_bool";}?>,可以对其使用强制转换或者settype()函数。,以下值被认为是FALSE:■the布尔值FALSE自身■the整型值0(零)■(零)■空字符串,以及字符串"0"■不包括任何元素的数组■不包括任何成员变量的对象()■特殊类型NULL(包括尚未设定的变量)■从没有任何标记(tags)的XML文档生成的SimpleXML对象所有其它值都被认为是TRUE(包括任何资源)。(即8或9),则后面其余数字会被忽略。Example#2八进制数的怪事<?phpvar_dump(01090);//八进制010=十进制8?>,将会被解释为float。同样如果执行的运算结果超出了integer范围,也会返回float。(key=>value,...)//键(key)可是是一个整数(integer)或字符串(string)//值(value)可以是任意类型的值<?php$arr=array("foo"=>"bar",12=>true);echo$arr["foo"];//barecho$arr[12];//1?>key可以是integer或者string。如果key是一个integer的标准表示,则被解释为整数(例如"8"将被解释为8,而"08"将被解释为"08")。key中的浮点数被取整为integer。在PHP中索引数组与关联数组是相同的,它们都可以同时包含整型和字符串的下标。,要对它用unset()。<?php$arr=array(5=>1,12=>2);$arr[]=56;//Thisisthesameas$arr[13]=56;//atthispointofthescript$arr["x"]=42;//Thisaddsanewelementto//thearraywithkey"x"unset($arr[5]);//Thisremovestheelementfromthearrayunset($arr);//Thisdeletesthewholearray?>:■被赋值为NULL。■尚未被赋值。■被unset()。NULL类型只有一个值,就是大小写不敏感的关键字NULL(你可以写成NULL,也可以写成null)。,它还可以是一个对象的方法,包括静态类的方法。Example#1回调函数(callback)示例<?php//普通的回调函数functionmy_callback_function(){echo'helloworld!';}//回调方法classMyClass{staticfunctionmyCallbackMethod(){echo'HelloWorld!';}}//Type1:Simplecallbackcall_user_func('my_callback_function');//Type2:lassmethodcallcall_user_func(array('MyClass','myCallbackMethod'));//Type3:Objectmethodcall$obj=newMyClass();call_user_func(array($obj,'myCallbackMethod'));//Type4:lassmethodcall()call_user_func('MyClass::myCallba