[PHP]PearµÄʹÓÃ
1. PEARµÄ°²×°, ÕâÀï½éÉÜÀûÓÃPHP5×Ô´øµÄBATÎļþ°²×°£¬ÐèÒªÄÜÉÏÍø¡£
a. ÔÚPHP5Ŀ¼ÏÂÕÒµ½go-pear.bat£¬Ë«»÷°²×°(±£Ö¤ÄÜÉÏÍø, ÒÔ±ãÏÂÔØ)£¬BAT×Ô¶¯´ÓÍøÉÏÏÂÔØPEARËùÐèµÄ¶«Î÷£»
b. °´ÕÕÌáʾÊäÈëһЩÉèÖÃÐÅÏ¢£¬Ö÷ÒªÊÇÒª°Ñ¾ÖÓòÍøµÄÍø¹Ø¼ÓÉÏ£¬Èçhttp://192.168.0.1:80/ , pearÒªÓÃÕâ¸öµØÖ··ÃÎÊInternet£¬ÈôÎÞ´úÀí·þÎñÆ÷ÔòÖ±½Ó»Ø³µ
c. È»ºó»áÌáʾһЩ°üºÍPHP°ó¶¨£¬Ñ¡ÔñY
2. °²×°ÍêPEARºó, ÒÔÏÂʾÀý¾ßÌåµ÷ÓÃ:
<?php
require_once 'DB.php';
//$dsn = 'sqlite:///E:/web2/Web_TY/sqlite/data/tydb.db?mode=0666';
$dsn = array(
'phptype' => 'mysql',
'username' => 'root',
'password' => '666666',
'hostspec' => 'localhost',
'database' => 'MyDbName'
);
$options = array(
'debug' => 2,
'portability' => DB_PORTABILITY_ALL
);
$db =& DB::connect($dsn, $options);
if (DB::isError($db)) {
die($db->getMessage());
}
$db->setFetchMode(DB_FETCHMODE_ASSOC);
$res =& $db->query('select * from counter');
if (DB::isError($res)) {
die($res->getMessage());
}
printf("ÐÐΪ£º%d,ÁÐΪ£º%d<br>", $res->numRows(), $res->numCols());
?>
3. pearʹÓÃÓöµ½µÄÎÊÌâ
a. ²âÊÔpear¶ÔSqliteµÄÖ§³Ö,°²×°¹ý³ÌÖз¢ÏÖ,ÀÏÊÇÌáʾphp_pdo.dllµÈÎÞ·¨¼ÓÔØ£¬µ¼ÖÂÎÞ·¨Ö§³ÖSqliteµÄÊý¾Ý²Ù×÷¡£¸ü»»ÐµÄphp°æ±¾ºó£¬¼ÓÔØ´íÎóûÓÐÁË£¡µ«ÔÚÐÞ¸Äphp.iniµÄinclude_pathºó£¨Ê¹Æä°üº¬smarty¿âµÄlibĿ¼£©£¬·¢ÏÖpear¿âµÄDB²Ù×÷ÓÖÎÞ·¨½øÐÐÁË¡£·¢ÏÖpear¿âµÄDBÁ¬½ÓÉèÖúÍphp.iniÖеÄinclude_pathÓйأ¬Èç¹û°üº¬ÆäËü·¾¶£¬½«µ¼ÖÂpear¿â²»ÄÜʹÓá£
b. ²âÊÔʹÓÃSqlite Database¡£·¢ÏÖphpÎÞ·¨Ê¶±ðlite.db£¬»³ÒÉÊÇÓÉÓÚphpÖ§³ÖsqliteµÄ°æ±¾£¨2.8.2£©£¬±È±¾»úÆ÷µÄ°æ±¾£¨3.0.3£©µÍ£¬µ¼ÖÂÎÞ·¨Ê¶±ð¸Ãdb¡£
Ïà¹ØÎĵµ£º
1£ºint strposº¯ÊýµÄ×÷ÓúÍCÓïÑÔÖеÄchar *strstr()Ò»Ñù
2£ºhtmlspecialchars()£¬½«ÌØÊâ×Ö·ûת»¯ÎªHTMLʵÌå(entity)
3£ºPHPÖ÷ÒªÓÃÓÚÒÔÏÂÈý¸öÁìÓò£º
1>£º·þÎñÆ÷¶Ë½Å±¾ 2>£ºÃüÁîÐнű¾ 3>£º±àд×ÀÃæÓ¦ÓóÌÐò
4£ºphp²¢ÖÃÔËËã·û(.)½«Á½¸ö×Ö·û´®Á¬½ÓÆðÀ´
5£ºphpµÄ×¢ÊͺÍCÓïÑÔµÄ×¢ÊÍÒ»Ñù¡ ......
1. $_GET
£º
http://localhost/a.php?a=ok
<?
echo
$_GET['a']; //ÏÔʾ"ok"
?>
2. $_SERVER['QUERY_STRING']
http://localhost/a.php?a=1&b=2&c=3
......
¡¡¡¡PHPÖеıäÁ¿Ò²ÓзÃÎÊÓò¡£×÷ÓÃÓò¿ÉÒÔʹÓÃPHPÖÐglobal
¡¡¡¡ÔÚº¯ÊýÄÚ²¿¡¢¶ÔÏóÖкÍÀàÖж¨ÒåµÄ¾Ö²¿±äÁ¿ÔÚº¯ÊýÍⲿÊÇÎÞ·¨±»·ÃÎʵ½µÄ£»Í¬Àí£¬ÔÚº¯ÊýÍⲿ¡¢¶ÔÏóÍâºÍÀàÍⶨÒåµÄ±äÁ¿£¬Èç¹ûûÓб»´«È룬ҲÊÇÎÞ·¨±»·ÃÎʵ½µÄ¡£
¡¡¡¡µ«ÊÇÈç¹ûÒ»¸öºÜ¶à±äÁ¿ÒªÍ¬Ê±±»´«ÈëºÜ¶àº¯Êý¡¢¶ÔÏó»òÕßÀ࣬ÎÒÃÇÒ²¿ÉÒÔÖ±½Ó½«ÆäÈ«¾Ö»¯¡£ÕâÑù²»½ö¿ÉÒÔ ......
ÏÂÃæ½éÉܼ¸ÖÖPHPÖÐÅжϡ¢Ñ»·µÄ¼¸ÖÖд·¨¡£
×îÆÕͨµÄÅжϣº
<?php
if( $args != NULL )
{
call_func($args);
}
?>
¶ÔÓÚµ¥ÐеÄÖ´ÐÐÓï¾ä£¬¿ÉÒÔд³É£º
<?php
if( $args != NULL ) call_func($args);
?>
Ò²¿ÉÒÔʹÓÃÒýºÅµÄ·½Ê½¡£
<?php
if( $args != NULL ):
call_func($args);
......
1. °²×°php5.1ÒÔÉϵİ汾,ÓÐÖ§³Öpdo!ΪÁËʹÄãµÄ»·¾³ÄÜÌṩ¶ÔpdoµÄÖ§³Ö!ÔÚphp.iniÎļþ¼ÓÈëÒÔÏÂ:
extension=php_pdo.dll
extension=php_pdo_mysql.dll
extension=php_pdo_mssql.dll(Ö§³ÖmssqlÊý¾Ý¿â)
2. ÒÔÏÂΪPHÖÐPDOµÄ¾ßÌåʹÓÃ
<?php
$dsn = 'mysql:dbname=MyDbName;host=localhost';
$user = 'root';
......