Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

[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¡£


Ïà¹ØÎĵµ£º

¹úÄÚPHP¿ªÔ´½¨Õ¾³ÌÐòÒ»ÀÀ

¹úÍâµÄ¿ªÔ´¼¼ÊõÒ²Ó°ÏìºÍÍÆ¶¯Á˹úÄÚ¿ªÔ´³ÌÐòµÄ·¢Õ¹£¬ÉÏÎÄÎÒ½éÉܵġ¶¹úÍâÓÅÐ㿪ԴPHP½¨Õ¾³ÌÐòÒ»ÀÀ¡·ÖУ¬ºÜ¶à¹úÍ⿪Դ³ÌÐò²¢²»Ì«·ûºÏÖйúÈ˵ÄʹÓÃϰ¹ß£¬¶ø¹úÄÚÓÐһЩ³§¼Ò»ò¸öÈËÒ²×öÁËһЩ²»´íµÄ²úÆ·£¬²»ÉÙ³ÌÐòÊÇÌṩԴ´úÂëÏÂÔØµÄ£¬ËäÈ»ÓÐЩÔÚÐí¿ÉЭÒéÉϺͿªÔ´Ðí¿ÉÖ¤ÓÐЩ³öÈ룬µ«ÆäÔÚʹÓÃÉÏ»¹ÊÇͦ·ûºÏÖйúÈ˵ÄʹÓÃϰ¹ß£¬½ñÌìÎÒ¾ ......

PHPѧϰ±Ê¼Ç

1£ºint strposº¯ÊýµÄ×÷ÓúÍCÓïÑÔÖеÄchar *strstr()Ò»Ñù
2£ºhtmlspecialchars()£¬½«ÌØÊâ×Ö·ûת»¯ÎªHTMLʵÌå(entity)
3£ºPHPÖ÷ÒªÓÃÓÚÒÔÏÂÈý¸öÁìÓò£º
   1>£º·þÎñÆ÷¶Ë½Å±¾  2>£ºÃüÁîÐнű¾  3>£º±àд×ÀÃæÓ¦ÓóÌÐò
4£ºphp²¢ÖÃÔËËã·û(.)½«Á½¸ö×Ö·û´®Á¬½ÓÆðÀ´
5£ºphpµÄ×¢ÊͺÍCÓïÑÔµÄ×¢ÊÍÒ»Ñù¡ ......

PHP ÖÐ×Ô¶¨Ò庯ÊýµÄ¼¸ÖÖ·½Ê½


PHPÖÐͨ³£Óм¸ÖÖ×Ô¶¨Ò庯ÊýµÄ·½·¨£¬ÏÂÃæ½éÉÜһϣ¬ÎÒÃÇʹÓõÄÊÇÕâÖÖ·½Ê½£º
<?php
function foo($arg)
{
return $arg
}
?>
µ±Ä³Ð©²ÎÊýΪ¿ÉÑ¡ÊÇ£¬¿ÉÒÔÕâÑù¶¨Ò壺
<?php
function foo($arg = NULL)
{
return $arg == NULL ? "" : $arg;
}
?>
µ±ÎÒÃDz»ÏÞÖÆ²ÎÊý¸öÊýµÄʱºò£¬Ò²¿ÉÒ ......

PHP Öг¤Á¬½ÓµÄʵÏÖ

¡¡¡¡Ã¿´ÎÎÒÃÇ·ÃÎÊ PHP ½Å±¾µÄʱºò£¬¶¼Êǵ±ËùÓеÄPHP½Å±¾Ö´ÐÐÍê³Éºó£¬ÎÒÃDzŵõ½·µ»Ø½á¹û¡£Èç¹ûÎÒÃÇÐèÒªÒ»¸ö½Å±¾³ÖÐøµÄÔËÐУ¬ÄÇôÎÒÃǾÍҪͨ¹ý PHP ³¤Á¬½ÓµÄ·½Ê½£¬À´´ïµ½ÔËÐÐÄ¿µÄ¡£
¡¡¡¡Ã¿¸ö PHP ½Å±¾¶¼ÏÞÖÆÁËÖ´ÐÐʱ¼ä£¬ËùÒÔÎÒÃÇÐèҪͨ¹ý set_time_limit À´ÉèÖÃÒ»¸ö½Å±¾µÄÖ´ÐÐʱ¼äΪÎÞÏÞ³¤£»È»ºóʹÓà flush() ºÍ ob_flush() ......

[PHP]PDOµ÷Óô洢¹ý³Ì

1. Êý¾Ý¿âÖÐÒÑ´´½¨´æ´¢¹ý³Ìuser_logon_check, PHPµ÷ÓÃʾÀýÈçÏÂ,
<?php
$dsn = 'mssql:dbname=MyDbName;host=localhost';
$user = 'sa';
$password = '666666';
try {
$dbCon = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
print 'Connection failed: '.$e->getMessage();
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ