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
Ïà¹ØÎĵµ£º
¡¾Ê²Ã´ÊÇMVC£¿¡¿
MVCÊÇÒ»¸ö¿ÉÒÔÈÃÄã°Ñ“Èý¸ö²¿·Ö£¨¼´MVCµÄÈ«³Æ£¬Model¡¢ View¡¢Controller£©”гµ÷µØ×é³ÉÒ»¸ö¸´ÔÓÓ¦ÓóÌÐòµÄ¸ÅÄî¡£Ò»Á¾Æû³µ¾ÍÊÇÒ»¸öÔÚÏÖʵÉú»îÖзdz£ºÃµÄMVCÀý×Ó¡£ÎÒÃÇ¿´³µ¶¼¿´Á½¸öView£¨ÏÔ Ê¾£©²¿·Ö£ºÄÚ²¿ºÍÍⲿ¡£¶øÕâÁ½¸ö¶¼Àë²»¿ªÒ»¸öController£ ......
ÈçºÎ²»Ê¹ÓÃprepared statment£¬¶øÊÇÓùýÂ˵ķ½·¨±ÜÃâSQL×¢ÈëÄØ£¿
Ò»°ãÀ´Ëµmysql×Ô´øµÄ¹ýÂ˺¯ÊýÊDZȽϿɿ¿µÄ¡£mysql_real_escape_string()
µ«ÊÇÕâ¸öº¯ÊýÔÚijЩ×Ö·û¼¯ÖÐÓÐÎÊÌ⣬±ÈÈçGBK¡£Èç¹ûÄãÓÃUTF8ÄÇû¹Øϵ¡£
ÔÚPHPÀïÉèÖÃÊý¾Ý¿âµÄ×Ö·û¼¯²»Ó¦¸ÃÓãºmysql_query("SET NAMES UTF8");
¶øÓ¦¸ÃÓãºmysql_set_charset()
ÕâÑù ......
<?php
// Á¬½Ó£¬Ñ¡ÔñÊý¾Ý¿â
$dbconn = pg_connect("host=localhost dbname=publishing user=www password=foo")
or die('Could not connect: ' . pg_last_error());
// Ö´ÐÐ SQL ²éѯ
$query = 'SELECT * from authors';
$result = pg_query($query) or die('Query failed: ' . pg_last_error( ......
PHPÍⲿ±äÁ¿Óë»·¾³±äÁ¿
PHPµÄÌصãÖ®Ò»¾ÍÊÇ¿ÉÒÔÓüòµ¥µÄ·½Ê½´¦Àí±íµ¥Êý¾Ý£¬»ñÈ¡»·¾³±äÁ¿¡£ÔÚPHPÖУ¬ÕâЩÍⲿÊý¾Ý»ò±äÁ¿±£´æÔÚÒ»ÖÖÌØÊâµÄÈ«¾Ö±äÁ¿Êý×éÖС£
±íµ¥Êý¾Ý
$_GET£º»ñÈ¡GETÇëÇó·¢Ë͵ÄÊý¾Ý
$_POST£º»ñÈ¡POSTÇëÇó·¢Ë͵ÄÊý¾Ý
$_REQUEST£º¿ÉÒÔͬʱ»ñÈ¡GETºÍPOSTÇëÇó·¢Ë͵ÄÊý¾Ý
¡¾Ê¾Àý¡¿
ÇëÇóURL£ºhttp://localh ......
PHPÊý¾ÝÀàÐÍת»»Ï¸½Ú
1¡¢Êý×Ö£¨ÕûÐκ͸¡µãÐÍÖ®¼ä¿ÉÒÔÏ໥ת»¯£©
ÕûÐÎת»»Îª¸¡µãÐÍ£ºÓÉÓÚ¸¡µãÐ͵ľ«¶È·¶Î§Ô¶´óÓÚÕûÐΣ¬ËùÒÔת»»ºóµÄÊýÖµ¾«¶È²»»á¸Ä±ä¡£
¸¡µãÐÍת»»ÎªÕûÐΣº½²×Ô¶¯ÉáÆúСÊ÷²¿·Ö£¬Ö»±£ÁôÕûÊý²¿·Ö¡£×¢£ºÈç¹ûÒ»¸ö¸¡µãÐͳ¬¹ýÕûÊýÈ¡ÖµµÄÓÐЧ·¶Î§£¬Æä½á¹û½«ÊÇÎÞ·¨È·¶¨µÄ£¨ÕûÊýµÄ×î´óÖµÔ¼ÊÇ2.147e9£©¡£
¡¾Ê¾Àý¡ ......