PHP ³õʶ
ÒÔS2µÄBBSÂÛ̳ÏîÄ¿×÷ΪÕû¸ö»ù´¡¿Î³ÌµÄ°¸Àý¡£
1.Á¬½ÓÊý¾Ý¿âºÍÖ´ÐеÚÒ»¸öSQLÓï¾ä:
1)PHPÌṩÁËÁ¬½ÓÊý¾Ý¿âµÄº¯Êý--mysqli_connect(agrs0,agrs1,agrs3)£¬ÎÒÃÇÖ±½ÓʹÓþͿÉÒÔÁË¡£
´Ëº¯Êý°üÀ¨Èý¸ö±ØÒªµÄ²ÎÊý£¬·Ö±ðΪ£ºlocalhost£¬Êý¾Ý¿âÓû§Ãû£¬Êý¾ÝÔ´¡£
ÒÔbbsÂÛ̳Á¬½ÓMySQLÊý¾Ý¿âΪÀý:
Á¬½ÓÊý¾Ý¿â£º
$db = mysqli_connect('localhost','root','bbs');
Ö´ÐÐSQLÓï¾ä£º
$sql="set names utf8"; //²åÈëÊý¾ÝʱµÄͳһ±àÂë¸ñʽÃüÁî¡£
mysqli_query('$db',$sql); //SQLÖ´ÐÐ
2)ÓÉÓÚIE¾Þ´óµÄÈÝ´íÄÜÁ¦ºÍPHPµÄÎÞ´íÎóÌáʾ£¬µ¼ÖÂÎÒÃÇÔÚÖ´ÐÐSQLÓï¾ä³ö´íʱ²»»áÏñJSPÒ»ÑùÃ÷È·µÄÌáʾÎÒÃÇ£¬ÎªÁËÎÒÃǵŤ×÷½øÕ¹¸ü˳Àû£¬ÕâʱÎÒÃǾÍÐèÒªÊÖ¶¯µÄÈÃÎÒÃǵĴíÎóÅ׳öÀ´£¬¾ßÌå´¦Àí·½Ê½ºÜÓÐÒÔϼ¸ÖÖ£º
a. ÔÚÖ´ÐеÄSQLÓï¾äºóÃæ½ô¸úÆäºóÌí¼ÓÒ»¾ä£ºecho $sql; "$sql" ¾ÍÊÇÎÒÃÇËùдµÄSQLÓï¾ä¡£
b.´ýÐø........
2.MYSQLÊý¾Ý¿âÂÒÂë´¦Àí
1) ÔÚ´´½¨±íʱעÒâÔÚ×îºó¼ÓÈëÒ»¾äÃüÁî¾Í¿ÉÒÔÁË£ºcharset ±àÂë¸ñʽ eg: charset utf8
2) ÔÚPHP´úÂëÀï(²åÈëÊý¾ÝʱµÄÏÈÖ´ÐÐÕâ¾ä´úÂë)£º mysql_query("SET NAMES utf8"); //²åÈëÊý¾ÝµÄͳһ±àÂë¸ñʽÃüÁî¡£
3.±êÇ©µÄÔÀí¾ÍÊǽ«ÎÒÃǵÄPHP½Å±¾´úÂëÌæ´ú³ÉÎÒÃÇÊìϤµÄÕýÔò±í´ïʽ¡£
4.ÔÚPHPÀïÖ´ÐÐSQLÓï¾äʱµÄ×¢ÒâÊÂÏ
1) µ±Ò»¸ö´úÂë¿éÐèÒªµ±×öÒ»¸öÕûÌåÀ´Ö´ÐÐʱ£¬ÎÒÃÇÐèÒª¶ÔÆä½øÐд¦Àí£¬Ò²¾ÍÊǽ«ÆäÓôóÀ¨ºÅÀ¨ÆðÀ´£ºeg: {$user['uPass']}
2) ÔÚPHPÀïµÄ SQLÓï¾ä²»»áÏñjsp ÀïÒ»Ñù»áͨ¹ý setString()À´×Ô¶¯Ê¶±ð±äÁ¿ÊÇ·ñΪ×Ö·û´®£¬ÓÉÓÚPHPÊÇÈõÓïÑÔ£¬ÎÒÃÇÐèÒª½«×Ö·û´®Êµ¼ÊµÄ±í´ï³öÀ´£¬¾ÍÊǽ«ÆäÓõ¥ÒýºÅÀ¨ÆðÀ´¡£
eg: '{$user['uName']}'
3) PHPÀïµÄº¯ÊýÐèÒªÓõ½PHPÀﶨÒåµÄÈ«¾Ö±äÁ¿Ê±ÐèÒªÔÚÒýÓõĺ¯ÊýÀïÓÃglobalÉùÃ÷һϡ£eg: global $db;
ÒÔBBSÂÛ̳ΪÀý,ÒÔÉÏÎÊÌâ¾ßÌå´¦ÀíÈçÏÂ:
<?php
// µ¼ÈëÊý¾Ý¿âÁ¬½Ó lib_db.php Îļþ
include('lib_db.php');18:05:24
// Ìí¼ÓÓû§º¯Êý
function addUser($user) //$user ÊÇÒ»¸öÊý×é
{
global $db;
$sql="insert into user value
Ïà¹ØÎĵµ£º
<p>04¼¶ÐÂÉúÃûµ¥</p>
<table border="1" width="80%" cellpadding="0">
<tr>
<td width="10%" align="center">Id</td>
<td width="20%" align="center">Name</td>
<td width="10%" align="center">Age</td>
<td width="10%" align="cent ......
ÕÒÁ˺ܶàÕâÑùµÄº¯Êý£¬»¹ÊǾõµÄÕâ¸ö×îºÃÁË
$a = 'aadfdsf¶á¶¥ÌæÒ»¿Ý»ù22245¶¥ÌæsdffhѹÏÂ';
/**
* ½ØÈ¡utf-8×Ö·û
* @param string $string
* @param int$length
*
* return string
*/
function cutstr($string, $length) {
preg_match_all("/./u", $string, $info);
$i = 0;
$str = '';
foreach($inf ......
¡¡¡¡¹¹Ô캯ÊýÊÇPHPÖÐ×ÜÒªµÄ»ù±¾Óï·¨£¬Ê²Ã´Êǹ¹Ô캯ÊýÄØ?ÎÒÃÇÕâÀï¾ÍÒ»ÆðÀ´¿´¿´PHP¹¹Ô캯Êý¡£Èç¹ûÄãÔÚÒ»¸öÀàÖÐÉùÃ÷Ò»¸öº¯Êý,ÃüÃûΪ__construct,Õâ¸öº¯Êý½«±»µ±³ÉÊÇÒ»¸ö¹¹Ô캯Êý²¢ÔÚ½¨Á¢Ò»¸ö¶ÔÏóʵÀýʱ±»Ö´ÐÐ.Çå³þµØ˵,__ÊÇÁ½¸öÏ»®Ïß.¾ÍÏñÆäËüÈκκ¯ÊýÒ»Ñù,¹¹Ô캯Êý¿ÉÄÜÓвÎÊý»òÕßĬÈÏÖµ.Äã¿ÉÒÔ¶¨ÒåÒ»¸öÀàÀ´½¨Á¢Ò»¸ö¶ÔÏó²¢½ ......
¶ÔÓÚPHP¿ª·¢ÕßÀ´Ëµ£¬×îÖØÒªµÄ¿ÖžÍÊǵ÷ÊÔÁË£¬È»¶øÓÉÓÚPHPÊÇÒ»ÖÖÈõÀàÐ͵ÄÓïÑÔ£¬ÕâÖÖÌØÐÂÍùÍù¾ö¶¨ÁËËüÔÚµ÷ÊÔ·½ÃæµÄһЩÀ§ÄÑ£¬Òò´ËºÃµÄµ÷ÊÔ·½·¨ºÍµ÷ÊÔ¹¤¾ßÖÁ¹ØÖØÒª£¬ÕâÀïÎÒÃÇÐèҪΪPHP¼¯³ÉZend_Debuggerµ÷ÊÔÆ÷£¬Í¨¹ýËü£¬ÎÞÂÛ½øÐб¾µØµ÷ÊÔ»¹ÊÇÔ¶³Ìµ÷ÊÔ£¬¶¼·Ç³£·½±ã£¬¾ßÌ弯³É·½·¨ÈçÏ£º
1¡¢ÏÂÔØZend_Debugger×é¼þ£¬¿ÉÒÔµ½Zend ......