phpÖÐempty()£¬is_null()£¬isset()£¬boolÖ®¼äµÄÇø±ð
´ÓÕâ¸öͼÖУ¬¿ÉÒÔºÜÇå³þµÄ¿´µ½Ò»ÖÖÁªÏµ£º
¼ÙÉè $var ÊÇÈκÎtype¡£
µ± empty($var) Ϊ true ʱ£¬ (bool)($var) Ϊ false ¡£·´Ö®ÒàÈ»¡£
ͬÑù£¬
µ± is_null($var) Ϊ true ʱ£¬ isset($var) Ϊ false ¡£·´Ö®ÒàÈ»¡£
¼ÙÈç:
$i=$j+1;
ÕâÀïµÄis_null($j)Ϊtrue
¿É¼û£º
issetÓÃÓÚÅжÏ䶨ÒåµÄÇé¿ö¡£
Empty¿ÉÒÔÅжÏ䶨ÒåºÍÒѶ¨Ò壬µ«ÊÇΪ¿Õ£¬Îª0µÄÇé¿ö¡£
Is_null¿ÉÒÔ¿´×öÊÇissetµÄ·´º¯Êý
If£¨$±í´ïʽ£©¿ÉÒÔ¿´×öÊÇemptyµÄ·´º¯Êý
µ±ÒªÅжϵÄÄÚÈÝΪÊý×éʱ£¬±íÖнö½öÂÞÁÐÁËÒ»ÖÖÇé¿ö£¬ÏÂÃæ²¹³äÁ½ÖÖÈÝÒ×Îó»áµÄÇé¿ö
PHP´úÂë
$b[]=null;
$b[]=null;
//ÊÓΪÊý×éÒÑ´æÔÚÇÒ²»Îª¿Õ
$c[]="";
$c[]="";
//ÊÓΪÊý×éÒÑ´æÔÚÇÒ²»Îª¿Õ
empty
(PHP 3, PHP 4, PHP 5)
empty -- ¼ì²éÒ»¸ö±äÁ¿ÊÇ·ñΪ¿Õ
ÃèÊö
bool empty ( mixed var )
Èç¹û var ÊÇ·Ç¿Õ»ò·ÇÁãµÄÖµ£¬Ôò empty() ·µ»Ø FALSE¡£»»¾ä»°Ëµ£¬""¡¢0¡¢"0"¡¢NULL¡¢FALSE¡¢array()¡¢var $var; ÒÔ¼°Ã»ÓÐÈκÎÊôÐԵĶÔÏ󶼽«±»ÈÏΪÊǿյģ¬Èç¹û var Ϊ¿Õ£¬Ôò·µ»Ø TRUE¡£
³ýÁ˵±±äÁ¿Ã»ÓÐÖÃֵʱ²»²úÉú¾¯¸æÖ®Í⣬empty() ÊÇ (boolean) var µÄ·´Òå´Ê¡£²Î¼ûת»»Îª²¼¶ûÖµ»ñÈ¡¸ü¶àÐÅÏ¢¡£
empty() Óë isset() µÄÒ»¸ö¼òµ¥±È½Ï¡£
<?php
$var = 0;
// ½á¹ûΪ true£¬ÒòΪ $var Ϊ¿Õ
if (empty($var)) {
echo '$var is either 0 or not set at all';
}
// ½á¹ûΪ false£¬ÒòΪ $var ÒÑÉèÖÃ
if (!isset($var)) {
echo '$var is not set at all';
}
?>
×¢: ÓÉÓÚÕâÊÇÒ»¸öÓïÑԽṹ¶ø·Çº¯Êý£¬Òò´ËËüÎÞ·¨±»±äÁ¿º¯Êýµ÷Óá£
×¢: empty() Ö»¼ì²â±äÁ¿£¬¼ì²âÈκηDZäÁ¿µÄ¶«Î÷¶¼½«µ¼Ö½âÎö´íÎó¡£»»¾ä»°Ëµ£¬ºó±ßµÄÓï¾ä½«²»»áÆð×÷Ó㺠empty(addslashes($name))¡£
isset
(PHP 3, PHP 4, PHP 5)
isset -- ¼ì²â±äÁ¿ÊÇ·ñÉèÖÃ
ÃèÊö
bool isset ( mixed var [, mixed var [, ...]] )
Èç¹û var ´æÔÚÔò·µ»Ø TRUE£¬·ñÔò·µ»Ø FALSE¡£
Èç¹ûÒѾʹÓà unset() ÊÍ·ÅÁËÒ»¸ö±äÁ¿Ö®ºó£¬Ëü½«²»ÔÙÊÇ isset()¡£ÈôʹÓà isset() ²âÊÔÒ»¸ö±»ÉèÖÃ³É NULL µÄ±äÁ¿£¬½«·µ»Ø FALSE¡£Í¬Ê±Òª×¢ÒâµÄÊÇÒ»¸ö NULL ×Ö½Ú£¨"\0"£©²¢²»µÈͬÓÚ PHP µÄ NULL ³£Êý¡£
¾¯¸æ: isset() Ö»ÄÜÓÃÓÚ±äÁ¿£¬ÒòΪ´«µÝÈκÎÆäËü²ÎÊý¶¼½«Ôì³É½âÎö´íÎó¡£ÈôÏë¼ì²â
Ïà¹ØÎĵµ£º
×î½ü¹«Ë¾ÓиöÍøÕ¾ÒªÏÈÅжϷþÎñÆ÷ÉϵÄÍøÒ³ÊÇ·ñ¿ÉÓã¬È»ºóÔÚ°ÑÖµÌá½»µ½Õâ¸öÍøÒ³ÉÏ¡£Ê¹ÓÃphpÀ´¼ì²âÍøÒ³ÊÇ·ñ¿ÉÓã¬Ã»Ôõô½Ó´¥¹ýphp£¬¸ãÁËÁ½Ì죬»ù±¾ÉÏÊÇ¿ÉÒÔ¼ì²âÁË¡£ÏÖ°Ñ´úÂëÌùÉÏ£º
<?php
//
$url = "http://blog.csdn.net/xuezhongsong/archive/2009/09/17/4561488.aspx";
$ ......
<%
rs.pagesize=14
page=cint(Request.QueryString("page"))
if page<1 then
page=1
elseif page>rs.pagecount then
page=rs.pagecount
end if
rs.AbsolutePage=page
IF rs.BOF and rs.eof then
Response.Write("<br><br>±¾Õ¾ÔÝÎÞÈÕÖ¾¼Ç¼£¡£¡<br><br>")
response.end
end if ......
·Ö±ðÏÂÔØÁËphp5.2.10ºÍ5.3.0°æ±¾µÄÔ´Â룬²éÕÒµ½ÀïÃæcall_user_function(ÔÚext/standard/basic_functions.c)µÄ·½·¨¡£
ÔÚ5.2.10°æ±¾Àcall_user_functionÓõÄÊDZê×¼µÄphp º¯ÊýµÄд·¨£¬ÓÃzvalÀàÐÍÀ´´æ´¢½ÓÊյIJÎÊý£¬µ÷ÓÃcall_user_function_exÀ´Ö´ÐÐÓû§µÄ·½·¨¡£Èç¹ûµ÷Óò»³É¹¦Ôò·ÖÎöÊDz»ÊǽÓÊÕµ½µÄ²ÎÊýÀïÓÐʲô´íÎó¡£
µ«Ô ......
ͻȻÏëÆðÁËÔÚÒ»´ÎÃæÊÔµÄʱºòÒªÎÒд³öδÀ´Ò»ÌìÊÇÐÇÆÚ¼¸£¬µ±Ê±Ã»Óиøд³öÀ´¡£ÏÖÔÚÏëÏ뻹ÊǾõµÃ¶ÔdateºÍmktimeµÄ¸ÅÄîºÜÄ£ºý£¬ÔÚÕâÀï¼Ç¼ÏÂÒÔ±¸ºóÓ㺳ÌÐòÈçÏÂ
<?php
echo date( "l dS 0f F Y h£ºi£ºs A" );
echo "<br>";
print("July 1, 2010 is on a " . date("l", mktime(0,0,0,7,11,2010)));
?>
Êä³ö½á¹û ......