PHPÊý¾ÝÀàÐÍת»»
PHPÊý¾ÝÀàÐÍת»»
PHPµÄÊý¾ÝÀàÐÍת»»ÊôÓÚÇ¿ÖÆ×ª»»£¬ÔÊÐíת»»µÄPHPÊý¾ÝÀàÐÍÓУº
£¨int£©¡¢£¨integer£©£º×ª»»³ÉÕûÐÎ
£¨float£©¡¢£¨double£©¡¢£¨real£©£º×ª»»³É¸¡µãÐÍ
£¨string£©£º×ª»»³É×Ö·û´®
£¨bool£©¡¢£¨boolean£©£º×ª»»³É²¼¶ûÀàÐÍ
£¨array£©£º×ª»»³ÉÊý×é
£¨object£©£º×ª»»³É¶ÔÏó
PHPÊý¾ÝÀàÐÍÓÐÈýÖÖת»»·½Ê½£º
ÔÚҪת»»µÄ±äÁ¿Ö®Ç°¼ÓÉÏÓÃÀ¨ºÅÀ¨ÆðÀ´µÄÄ¿±êÀàÐÍ
ʹÓÃ3¸ö¾ßÌåÀàÐ͵Äת»»º¯Êý£¬intval()¡¢floatval()¡¢strval()
ʹÓÃͨÓÃÀàÐÍת»»º¯Êýsettype(mixed var,string type)
µÚÒ»ÖÖת»»·½Ê½£º (int) (bool) (float) (string) (array) (object)
Îı¾²é¿´¸´ÖÆ´úÂë´òÓ¡¹ØÓÚ
<?php
$num1=3.14;
$num2=(int)$num1;
var_dump($num1); //Êä³öfloat(3.14)
var_dump($num2); //Êä³öint(3)
?>
<?php
$num1=3.14;
$num2=(int)$num1;
var_dump($num1); //Êä³öfloat(3.14)
var_dump($num2); //Êä³öint(3)
?>
µÚ¶þÖÖת»»·½Ê½£º intval() floatval() strval()
Îı¾²é¿´¸´ÖÆ´úÂë´òÓ¡¹ØÓÚ
<?php
$str="123.9abc";
$int=intval($str); //ת»»ºóÊýÖµ£º123
$float=floatval($str); //ת»»ºóÊýÖµ£º123.9
$str=strval($float); //ת»»ºó×Ö·û´®£º"123.9"
?>
<?php
$str="123.9abc";
$int=intval($str); //ת»»ºóÊýÖµ£º123
$float=floatval($str); //ת»»ºóÊýÖµ£º123.9
$str=strval($float); //ת»»ºó×Ö·û´®£º"123.9"
?>
µÚÈýÖÖת»»·½Ê½£º settype();
Îı¾²é¿´¸´ÖÆ´úÂë´òÓ¡¹ØÓÚ
<?php
$num4=12.8;
$flg=settype($num4,"int");
var_dump($flg); //Êä³öbool(true)
var_dump($num4); //Êä³öint(12)
?>
<?php
$num4=12.8;
$flg=settype($num4,"int");
var_dump($flg); //Êä³öbool(true)
var_dump($num4); //Êä³öint(12)
?>
365PHPÃâ·ÑÊÓÆµ½Ì³ÌÏÂÔØ£º PHP½Ì³ÌÊÓÆµ,Ãâ·ÑÊÓÆµÏÂÔØ -PHPÊý¾ÝÀàÐÍת»»
×÷ÕߣºÂíÃ÷@PHPÅàѵ PHPÐÞ¶©1.0 2009-09
365PHP£¬ÖйúPHPÔÚÏßÅàѵ
Ïà¹ØÎĵµ£º
phpÎļþ
<?php
mysql_connect("localhost","","");
mysql_query("set names 'gb2312'");
mysql_select_db("shop");
$sqlstr="select * from goods";
require 'smarty/libs/Smarty.class.php';
$smarty = new Smarty;//ÉèÖø÷¸öĿ¼µÄ·¾¶£¬ÕâÀïÊǰ²×°µÄÖØµã
$smarty->template_dir ="smarty/templates/templa ......
$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½Ø¶Ï ......
Ò»¡¢µÇ½
1.½øÈëlinux
2.Óû§Ãû: root
3.¿ÚÁî:123456
4.mysql Óû§Ãû root ÃÜÂë 123456
¶þ¡¢Æô¶¯mysqlÓëapache·þÎñ
1.Æô¶¯mysqÊý¾Ý¿â:/usr/local/mysql/bin/./mysqld_safe --user=mysql &
2.Í£Ö¹mysqlÊý¾Ý¿â:/usr/local/mysql/bin/mysqladmin -u root -p shutdown
3.Æô¶¯apache: /usr/local/apache2/bin/./ap ......
class lamp
{
public function __construct()
{
}
public function __get($var) //»ñÈ¡²»´æÔÚµÄÊôÐÔʱµ÷ÓÃ
{
echo "²»´æÔÚ±äÁ¿$var<br>";
}
public function __set($var ......
PHPÊý¾ÝÀàÐÍת»»Ï¸½Ú
1¡¢Êý×Ö£¨ÕûÐκ͸¡µãÐÍÖ®¼ä¿ÉÒÔÏ໥ת»¯£©
ÕûÐÎת»»Îª¸¡µãÐÍ£ºÓÉÓÚ¸¡µãÐ͵ľ«¶È·¶Î§Ô¶´óÓÚÕûÐΣ¬ËùÒÔת»»ºóµÄÊýÖµ¾«¶È²»»á¸Ä±ä¡£
¸¡µãÐÍת»»ÎªÕûÐΣº½²×Ô¶¯ÉáÆúСÊ÷²¿·Ö£¬Ö»±£ÁôÕûÊý²¿·Ö¡£×¢£ºÈç¹ûÒ»¸ö¸¡µãÐͳ¬¹ýÕûÊýȡֵµÄÓÐЧ·¶Î§£¬Æä½á¹û½«ÊÇÎÞ·¨È·¶¨µÄ£¨ÕûÊýµÄ×î´óÖµÔ¼ÊÇ2.147e9£©¡£
¡¾Ê¾Àý¡ ......