PHPÍⲿ±äÁ¿Óë»·¾³±äÁ¿
PHPÍⲿ±äÁ¿Óë»·¾³±äÁ¿
PHPµÄÌصãÖ®Ò»¾ÍÊÇ¿ÉÒÔÓüòµ¥µÄ·½Ê½´¦Àí±íµ¥Êý¾Ý£¬»ñÈ¡»·¾³±äÁ¿¡£ÔÚPHPÖУ¬ÕâЩÍⲿÊý¾Ý»ò±äÁ¿±£´æÔÚÒ»ÖÖÌØÊâµÄÈ«¾Ö±äÁ¿Êý×éÖС£
±íµ¥Êý¾Ý
$_GET£º»ñÈ¡GETÇëÇó·¢Ë͵ÄÊý¾Ý
$_POST£º»ñÈ¡POSTÇëÇó·¢Ë͵ÄÊý¾Ý
$_REQUEST£º¿ÉÒÔͬʱ»ñÈ¡GETºÍPOSTÇëÇó·¢Ë͵ÄÊý¾Ý
¡¾Ê¾Àý¡¿
ÇëÇóURL£ºhttp://localhost/test.php?username=alex&pwd=365php
Îı¾²é¿´¸´ÖÆ´úÂë´òÓ¡¹ØÓÚ
<?php
//»ñÈ¡GETÇëÇóÊý¾Ý
echo $_GET['username']; //Êä³öalex
echo $_GET['pwd']; //Êä³ö365php
?>
<?php
//»ñÈ¡GETÇëÇóÊý¾Ý
echo $_GET['username']; //Êä³öalex
echo $_GET['pwd']; //Êä³ö365php
?>
¡¾Ê¾Àý¡¿
Îı¾²é¿´¸´ÖÆ´úÂë´òÓ¡¹ØÓÚ
<form method="POST">
Óû§Ãû£º<input type="text" name="uname" /><br />
ÃÜÂ룺<input type="text" name="pwd" /><br />
<input type="submit" value="怬" />
</form>
<?php
echo $_POST["uname"]; //Êä³öÓû§ÔÚ±íµ¥ÉÏÊäÈëµÄÓû§Ãû
echo $_POST["pwd"]; //Êä³öÓû§ÔÚ±íµ¥ÉÏÊäÈëµÄÃÜÂë
echo $_REQUEST["uname"]; //$_REQUESTÒ²¿ÉÒÔ»ñÈ¡µ½POSTÊý¾Ý
print_r($_REQUEST);
?>
<form method="POST">
Óû§Ãû£º<input type="text" name="uname" /><br />
ÃÜÂ룺<input type="text" name="pwd" /><br />
<input type="submit" value="怬" />
</form>
<?php
echo $_POST["uname"]; //Êä³öÓû§ÔÚ±íµ¥ÉÏÊäÈëµÄÓû§Ãû
echo $_POST["pwd"]; //Êä³öÓû§ÔÚ±íµ¥ÉÏÊäÈëµÄÃÜÂë
echo $_REQUEST["uname"]; //$_REQUESTÒ²¿ÉÒÔ»ñÈ¡µ½POSTÊý¾Ý
print_r($_REQUEST);
?>
»·¾³±äÁ¿
$_ENV
$_SERVER
°üº¬ÁËWeb·þÎñÆ÷µÄһЩÅäÖÃÐÅÏ¢£¬ÒÔ¼°ä¯ÀÀÆ÷µÄһЩ״̬ÐÅÏ¢£¬Ê¹Óú¯Êýphpinfo()¿ÉÒÔ·µ»Ø¸ü¶àµÄ»·¾³ÐÅÏ¢£¬ÆäÖаüº¬ÁË$_ENVºÍ$_SERVERµÄÄÚÈÝ¡£
$_ENV°üº¬£º
[TEMP] =&
Ïà¹ØÎĵµ£º
PHP5.0ºó£¬phpÃæÏò¶ÔÏóÌá³É¸ü¶à·½·¨£¬Ê¹µÃphp¸ü¼ÓµÄÇ¿´ó£¡£¡
һЩÔÚPHP½ÐħÊõ·½·¨µÄº¯Êý£¬ÔÚÕâÀï½éÉÜһϣºÆäʵÔÚÒ»°ãµÄÓ¦ÓÃÖУ¬ÎÒÃǶ¼ÐèÒªÓõ½ËûÃÇ£¡£¡
1.__construct() µ±ÊµÀý»¯Ò»¸ö¶ÔÏóµÄʱºò£¬Õâ¸ö¶ÔÏóµÄÕâ¸ö·½·¨Ê×Ïȱ»µ÷Óá£
Java´úÂë
class Test { function __construct() { ec ......
ÈçºÎ²»Ê¹ÓÃprepared statment£¬¶øÊÇÓùýÂ˵ķ½·¨±ÜÃâSQL×¢ÈëÄØ£¿
Ò»°ãÀ´Ëµmysql×Ô´øµÄ¹ýÂ˺¯ÊýÊDZȽϿɿ¿µÄ¡£mysql_real_escape_string()
µ«ÊÇÕâ¸öº¯ÊýÔÚijЩ×Ö·û¼¯ÖÐÓÐÎÊÌ⣬±ÈÈçGBK¡£Èç¹ûÄãÓÃUTF8ÄÇû¹Øϵ¡£
ÔÚPHPÀïÉèÖÃÊý¾Ý¿âµÄ×Ö·û¼¯²»Ó¦¸ÃÓãºmysql_query("SET NAMES UTF8");
¶øÓ¦¸ÃÓãºmysql_set_charset()
ÕâÑù ......
$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 echo();2 print();3 die();4 printf();5 sprintf();6 print_r();7 var_dump();
1 echo()
¿ÉÒÔͬʱÊä³ö¶à¸ö×Ö·û´®,¿ÉÒÔ¶à¸ö²ÎÊý,²¢²»ÐèÒªÔ²À¨ºÅ,ÎÞ·µ»ØÖµ¡£
2 print()
Ö»¿ÉÒÔͬʱÊä³öÒ»¸ö×Ö·û´®£¬Ò»¸ö²ÎÊý,ÐèÒªÔ²À¨ºÅ,Óзµ»ØÖµ,µ±ÆäÖ´ÐÐʧ°Üʱ·µflase .print µÄÓ÷¨ºÍCÓï ......
ËäÈ»PHPÌṩÁ˺ܶ๦ÄÜÎÒÃÇ£¬µ«ÓÐЩÊÂÇ黹ûÓд¦ÀíÕâЩ·Ç³£·½±ã¡£ÀýÈ磬PHPÌṩµÄÈÕÆÚ¹¦ÄÜ£¬Ê±¼äºÜÓÐÏÞ¡£ MySQLÒѾÌṩÁËÐí¶àÎÒÃÇÕâЩ¹¦ÄÜ¡£ÎÒ¿ÉÒÔʹÓÃMySQLº¯ÊýÀ´´¦ÀíPHPµÄ¹ý³Ì£¿ÎÒÔÚÏÂÃæµÄ³¢ÊÔ¡£
“£¿ PHPµÄ
$ data_time =“1998-12-31 23:59:59”;
$ connect_id = mysql_connect£¨'±¾µØÖ÷»ú'£©;
......