PHP³£Á¿
PHP³£Á¿
³£Á¿Êǹ̶¨µÄÊýÖµÀýÈçÔ²ÖÜÂÊ£¬ÓÃÒ»¸ö¼òµ¥µÄ±êʶ·û½øÐж¨Ò壨Ãû×Ö£©¡£³£Á¿Ä¬ÈÏΪ´óСдÃô¸Ð¡£°´ÕÕ¹ßÀý³£Á¿±êʶ·û×ÜÊÇ´óдµÄ¡£
³£Á¿ÃûºÍÆäËüÈκΠPHP ±êÇ©×ñÑͬÑùµÄÃüÃû¹æÔò¡£ºÏ·¨µÄ³£Á¿ÃûÒÔ×Öĸ»òÏ»®Ïß¿ªÊ¼£¬ºóÃæ¸ú×ÅÈκÎ×Öĸ£¬Êý×Ö»òÏ»®Ïß¡£
³£Á¿µÄ¶¨Ò壺¿ÉÒÔÓà define( ) º¯ÊýÀ´¶¨Òå³£Á¿¡£Ò»¸ö³£Á¿Ò»µ©±»¶¨Ò壬¾Í²»ÄÜÔٸıä»òÕßÈ¡Ïû¶¨Òå¡£
³£Á¿·ÖΪ£ºÄÚÖó£Á¿£¨PHPϵͳÌṩµÄÔÚÈκÎÒ³ÃæÊýÖµ²»»á¸Ä±ä£©ºÍ×Ô¶¨Òå³£Á¿¡£
³£Á¿Ö»ÄÜ°üº¬±êÁ¿Êý¾Ý£¨boolean£¬integer£¬float ºÍ string£©¡£
PHPһЩ³£¼ûµÄϵͳ³£Á¿£¨²¿·Ö£©
PHP_OS:ÏÔʾ·þÎñÆ÷µÄ²Ù×÷ϵͳ°æ±¾
PHP_VERSION:ÏÔʾPHP°æ±¾
__FILE__:PHPÎļþÃû,¼ÙÈçÊÇÒýÓÃÎļþ,ÔòÏÔʾÒýÓÃÎļþÃû
__LINE__:PHPÎļþµÄÐÐÊý TRUE FALSE:±íʾÕæ¼ÙµÄ³£Á¿
E_ERROR:Ö¸Ã÷ÁË´úÂëÖÐ×î½üµÄ´íÎó´¦
E_WARNING:Ö¸Ã÷ÁË´úÂëÖÐ×î½üµÄ¾¯¸æ´¦
E_PARSE:·ÖÎö´úÂëºÎ´¦ÓÐ×ÅDZÔÚµÄÎÊÌâ
E_NOTICE:Ϊ·¢Éú²»Ñ°³£µ«²»Ò»¶¨ÊÇ´íÎóµÄµØ·½
×Ô¶¨Òå³£Á¿
ÓÃdefine( )º¯ÊýÀ´×Ô¶¨Òå³£Á¿¡£
define(“mycomputer”, “IBM”);
¶¨Òå³£Á¿£ºmycomputer ³£Á¿µÄֵΪ IBM
defined(“mycomputer”); ¼ì²â³£Á¿ÊÇ·ñ±»¶¨Ò壬ÒѶ¨Òå·µ»Ø1 ·ñÔò·µ»Ø¿Õ
Àý£º
Îı¾²é¿´¸´ÖÆ´úÂë´òÓ¡¹ØÓÚ
define('NAME', 'php');
define('NAME', 'linux');
echo NAME;
define('NAME', 'php');
define('NAME', 'linux');
echo NAME;
¡¾Ê¾Àý¡¿
Îı¾²é¿´¸´ÖÆ´úÂë´òÓ¡¹ØÓÚ
<?php
// ºÏ·¨µÄ³£Á¿Ãû
define("FOO", "something");
define("FOO2", "something else");
define("FOO_BAR", "something more"); // ·Ç·¨µÄ³£Á¿Ãû define("2FOO", "something");
// ³£Á¿µÄÊä³ö £¨×¢Òâ´óСд£©
echo FOO;
echo FOO2;
?>
<?php
// ºÏ·¨µÄ³£Á¿Ãû
define("FOO", "something");
define("FOO2", "something else");
define("FOO_BAR", "something more");// ·Ç·¨µÄ³£Á¿Ãûdefine("2FOO", "something");
// ³£Á¿µÄÊä³ö £¨×¢Òâ´óСд£©
echo FOO;
echo FOO2;
?>
365PHP
Ïà¹ØÎĵµ£º
$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£¨'±¾µØÖ÷»ú'£©;
......
class lamp
{
public function __construct()
{
}
public function __get($var) //»ñÈ¡²»´æÔÚµÄÊôÐÔʱµ÷ÓÃ
{
echo "²»´æÔÚ±äÁ¿$var<br>";
}
public function __set($var ......
PHPÁ÷³Ì¿ØÖÆ
ÔÚÈκÎÒ»ÃųÌÐòÉè¼ÆÓïÑÔÖУ¬¶¼ÐèÒªÖ§³ÖÂú×ã³ÌÐò½á¹¹»¯ËùÐèÒªµÄÈýÖÖ»ù±¾½á¹¹
˳Ðò½á¹¹
·ÖÖ§½á¹¹£¨Ñ¡Ôñ½á¹¹£©
Ñ»·½á¹¹
ÔÚPHPÖУ¬ÎªÖ§³ÖÕâÈýÖֽṹ£¬ÌṩÁËʵÏÖÕâÈýÖֽṹËùÐèµÄÓï¾ä¡£
1¡¢Ë³Ðò½á¹¹£º
ÔÚ³ÌÐò½á¹¹ÖУ¬×î»ù±¾µÄ¾ÍÊÇ˳Ðò½á¹¹¡£³ÌÐò»á°´ÕÕ×ÔÉ϶øϵÄ˳ÐòÖ´ÐдúÂ룬»ù±¾ÐÎʽΪ£º
Óï¾ä1;
Óï ......