PHPÊý¾ÝÀàÐÍת»»Ï¸½Ú
PHPÊý¾ÝÀàÐÍת»»Ï¸½Ú
1¡¢Êý×Ö£¨ÕûÐκ͸¡µãÐÍÖ®¼ä¿ÉÒÔÏ໥ת»¯£©
ÕûÐÎת»»Îª¸¡µãÐÍ£ºÓÉÓÚ¸¡µãÐ͵ľ«¶È·¶Î§Ô¶´óÓÚÕûÐΣ¬ËùÒÔת»»ºóµÄÊýÖµ¾«¶È²»»á¸Ä±ä¡£
¸¡µãÐÍת»»ÎªÕûÐΣº½²×Ô¶¯ÉáÆúСÊ÷²¿·Ö£¬Ö»±£ÁôÕûÊý²¿·Ö¡£×¢£ºÈç¹ûÒ»¸ö¸¡µãÐͳ¬¹ýÕûÊýÈ¡ÖµµÄÓÐЧ·¶Î§£¬Æä½á¹û½«ÊÇÎÞ·¨È·¶¨µÄ£¨ÕûÊýµÄ×î´óÖµÔ¼ÊÇ2.147e9£©¡£
¡¾Ê¾Àý¡¿
Îı¾²é¿´¸´ÖÆ´úÂë´òÓ¡¹ØÓÚ
<?php
$real_num=3.1e9;
echo $real_num;
echo (int)$real_num; //Êä³öÒ»¸ö²»È·¶¨µÄÖµ,ÒòΪÒç³öµÄ²¿·ÖÒѾ¶ªÊ§¡£
?>
<?php
$real_num=3.1e9;
echo $real_num;
echo (int)$real_num; //Êä³öÒ»¸ö²»È·¶¨µÄÖµ,ÒòΪÒç³öµÄ²¿·ÖÒѾ¶ªÊ§¡£
?>
2¡¢²¼¶ûÐÍ
ÒÔÏÂÀàÐÍת»»Îª²¼¶ûÀàÐ͵Äfalse£¬ÆäËûµÄת»»Îªtrue
0ת»»Îªfalse
0.0ת»»Îªfalse
¿Õ°××Ö·û""ºÍ×Ö·û´®"0"ת»»Îªfalse
ûÓгÉÔ±µÄÊý×éarray()ת»»Îªfalse
NULLת»»Îªfalse
3¡¢×Ö·û´®
Êýֵת×Ö·û´®¾ÍÊÇ°´ÕÕÊýÖµÔ±¾µÄ¸ñʽת»»£»×Ö·û´®×ª»»ÎªÊý×Ö£¬×ª»»ºóµÄÊý×ÖÊÇ´Ó×Ö·û´®¿ªÊ¼²¿·ÖµÄÊýÖµÐÍ×Ö·û´®£¬ÊýÖµÐÍ×Ö·û´®°üÀ¨Õý¸ºÖµºÍÓÿÆѧ¼ÆÊý·¨±íʾµÄÊý×Ö¡£
¡¾Ê¾Àý¡¿
Îı¾²é¿´¸´ÖÆ´úÂë´òÓ¡¹ØÓÚ
<?php
$number=intval("5.6abc"); //5
$number=(float)"+5.6abc"; //5.6
$number=floatval("-1.2e3f4g5"); //-1.2e3
$result="12.3xy45"-6; //6.3
$result="xy1234"/5; //0
$result="1.2.3.4"*5; //6
$result=1+"-1.3e3"; //-1299
?>
<?php
$number=intval("5.6abc"); //5
$number=(float)"+5.6abc"; //5.6
$number=floatval("-1.2e3f4g5"); //-1.2e3
$result="12.3xy45"-6; //6.3
$result="xy1234"/5; //0
$result="1.2.3.4"*5; //6
$result=1+"-1.3e3"; //-1299
?>
²¼¶ûÀàÐÍת×Ö·û´®£¬falseת¿Õ×Ö·û´®""£¬trueת"1"
Êý×éת×Ö·û´®£¬ÊÇ"Array"
¶ÔÏóת×Ö·û´®£¬ÊÇ"Object"
×ÊԴת×Ö·û´®£¬ÊÇ"Resource id#1"
4¡¢Êý×é
²¼¶û¡¢Êý×ÖºÍ×Ö·û´®×ª»»ÎªÊý×飬½«µÃµ½Ò»¸ö°ü
Ïà¹ØÎĵµ£º
<?php
function toFixLen($str,$len){ //¹Ì¶¨³¤¶È×Ö·û´®µÄ½ØÈ¡
if($len>=strlen($str)||!$len) return $str;
$len-=3;
  ......
ÒýÓÃhttp://www.icnote.com/Mysql-php-connector/
ÓÉÓÚ¹«Ë¾µÄ·þÎñÆ÷¿ªÊ¼Ö»ÊÇÓÃÓÚjavaµÄÖ§³Ö£¬×°ÁËapache£¬mysql£¬php£¬µ«ÊÇphpµÄ°²×°Ã»ÓжÔmysql½øÐÐÖ§³Ö£¬½ñÌì¶ÔËû½øÐÐÁËÀ©Õ¹£¬¼Ç¼ÈçÏ¡£
Ê×ÏÈ£¬°²×°mysqlºÍphpµÄÁ¬½ÓÀ©Õ¹£¬ÐèÒªÒÔÏ°ü¡£¿ÉÒÔÔÚhttp://rpmfind.net/
ÕÒµ½£¬¸ù ......
$ip = "1.1.1.255".chr(0)."haha";
if(ereg("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$",$ip)) {
echo $ip;
} else {
echo "unknown";
}
Õâ¸öeregÕýÔòÏÞÖÆÁË$ipµÄÊý¾ÝΪxxx.xxx.xxx.xxxÕâÑùµÄÐÎʽ£¬±íÃæÉÏ¿´ÉÏÃæµÄ´úÂëÓ¦¸ÃÊä³ö"unknown"£¬¶øʵ¼ÊÈ´Êä³öÁË"1.1.1.255haha"£¬ÒòΪeregº¯Êý´æÔÚNULL½Ø¶Ï ......
ËäÈ»PHPÌṩÁ˺ܶ๦ÄÜÎÒÃÇ£¬µ«ÓÐЩÊÂÇ黹ûÓд¦ÀíÕâЩ·Ç³£·½±ã¡£ÀýÈ磬PHPÌṩµÄÈÕÆÚ¹¦ÄÜ£¬Ê±¼äºÜÓÐÏÞ¡£ MySQLÒѾÌṩÁËÐí¶àÎÒÃÇÕâЩ¹¦ÄÜ¡£ÎÒ¿ÉÒÔʹÓÃMySQLº¯ÊýÀ´´¦ÀíPHPµÄ¹ý³Ì£¿ÎÒÔÚÏÂÃæµÄ³¢ÊÔ¡£
“£¿ PHPµÄ
$ data_time =“1998-12-31 23:59:59”;
$ connect_id = mysql_connect£¨'±¾µØÖ÷»ú'£©;
......
PHP±í´ïʽ
±í´ïʽÊdz£Á¿¡¢±äÁ¿ºÍÔËËã·ûµÄ×éºÏ
±í´ïʽÊÇPHPÖеÄÖØÒªÄÚÈÝ£¬PHPÖм¸ºõËùÓеĶ«Î÷¶¼¿ÉÒÔ³ÆΪ±í´ïʽ
$x=10;
$y=($x=10);
$y+=($x=10);
$z=&$x;
$condition?$true_item:$false_item;
PHPÔËËã·û
ÔËËã·ûÊÇÓÃÀ´¶ÔÊýÖµ»ò±äÁ¿½øÐÐijÖÖ²Ù×÷ÔËËãµÄ·ûºÅ¡£Ò»°ãµØ˵£¬ÔËËã·û¿ÉÒÔ´øÓÐ1¸ö¡¢2¸ö»òÕ߸ü¶à¸öÔËË ......