phpå®å
¨ç¯å¼è¿æ»¤ç¨æ·è¾å
¥ç人åæ°
è§å 1ï¼ç»ä¸è¦ä¿¡ä»»å¤é¨æ°æ®æè¾å
¥
å
³äºWebåºç¨ç¨åºå®å
¨æ§ï¼å¿
须认è¯å°ç第ä¸ä»¶äºæ¯ä¸åºè¯¥ä¿¡ä»»å¤é¨æ°æ®ãå¤é¨æ°æ®(outside data) å
æ¬ä¸æ¯ç±ç¨åºåå¨PHP代ç ä¸ç´æ¥è¾å
¥çä»»ä½æ°æ®ãå¨éåæªæ½ç¡®ä¿å®å
¨ä¹åï¼æ¥èªä»»ä½å
¶ä»æ¥æº(æ¯å¦ GET åéã表å POSTãæ°æ®åºãé
ç½®æ件ãä¼è¯åéæ cookie)çä»»ä½æ°æ®é½æ¯ä¸å¯ä¿¡ä»»çã
ä¾å¦ï¼ä¸é¢çæ°æ®å
ç´ å¯ä»¥è¢«è®¤ä¸ºæ¯å®å
¨çï¼å 为å®ä»¬æ¯å¨PHPä¸è®¾ç½®çã
å¤å¶ä»£ç 代ç å¦ä¸:
<?php
$myUsername = 'tmyer';
$arrayUsers = array('tmyer', 'tom', 'tommy');define(âGREETINGâ, 'hello there' . $myUsername);?>
ä½æ¯ï¼ä¸é¢çæ°æ®å
ç´ é½æ¯æççµçã
æ¸
å 2. ä¸å®å
¨ãæççµç代ç
å¤å¶ä»£ç 代ç å¦ä¸:
<?php
$myUsername = $_POST['username']; //tainted!
$arrayUsers = array($myUsername, 'tom', 'tommy'); //tainted!
define(âGREETINGâ, 'hello there' . $myUsername); //tainted!
?>
为 ä»ä¹ç¬¬ä¸ä¸ªåé $myUsername æ¯æççµçï¼å 为å®ç´æ¥æ¥èªè¡¨å POSTãç¨æ·å¯ä»¥å¨è¿ä¸ªè¾å
¥åä¸è¾å
¥ä»»ä½å符串ï¼å
æ¬ç¨æ¥æ¸
é¤æ件æè¿è¡ä»¥åä¸ä¼ çæ件çæ¶æå½ä»¤ãæ¨å¯è½ä¼é®ï¼âé¾éä¸è½ä½¿ç¨åªæ¥ååæ¯ A-Z ç客æ·ç«¯ï¼JavascrÄ«ptï¼è¡¨åæ£éªèæ¬æ¥é¿å
è¿ç§å±é©åï¼âæ¯çï¼è¿æ»æ¯ä¸ä¸ªæ好å¤çæ¥éª¤ï¼ä½æ¯æ£å¦å¨åé¢ä¼çå°çï¼ä»»ä½äººé½å¯ä»¥å°ä»»ä½è¡¨åä¸è½½ å°èªå·±çæºå¨ä¸ï¼ä¿®æ¹å®ï¼ç¶åéæ°æ交ä»ä»¬éè¦çä»»ä½å
容ã
解å³æ¹æ¡å¾ç®åï¼å¿
须对 $_POST['username'] è¿è¡æ¸
ç代ç ãå¦æä¸è¿ä¹åï¼é£ä¹å¨ä½¿ç¨ $myUsername çä»»ä½å
¶ä»æ¶åï¼æ¯å¦å¨æ°ç»æ常éä¸ï¼ï¼å°±å¯è½æ±¡æè¿äºå¯¹è±¡ã
对ç¨æ·è¾å
¥è¿è¡æ¸
ççä¸ä¸ªç®åæ¹æ³æ¯ï¼ä½¿ç¨æ£å表达å¼æ¥å¤çå®ãå¨è¿ä¸ªç¤ºä¾ä¸ï¼åªå¸ææ¥ååæ¯ãå°å符串éå¶ä¸ºç¹å®æ°éçå符ï¼æè
è¦æ±ææåæ¯é½æ¯å°åçï¼è¿å¯è½ä¹æ¯ä¸ªå¥½ä¸»æã
æ¸
å 3. 使ç¨æ·è¾å
¥åå¾å®å
¨
å¤å¶ä»£ç 代ç å¦ä¸:
<?php
$myUsername = cleanInput($_POST['username']); //clean!
$arrayUsers = array($myUsername, 'tom', 'tommy'); //clean!
define(âGREETINGâ, 'hello there' . $myUsername); //clean!
function cleanInput($input){
$clean = strtolower($input);
$clean = preg_replace(â/[^a-z]/â, ââ, $clean);$clean = substr($clean,0,12);
return $clean;
}
?>
è§å 2ï¼ç¦ç¨é£äºä½¿å®å
¨æ§é¾ä»¥å®æ½ç PHP 设置已ç»ç¥éäºä¸è½ä¿¡ä»»ç¨æ·è¾å
¥ï¼è¿åºè¯¥ç¥éä¸åºè¯¥ä¿¡ä»»æºå¨ä¸é
ç½® PHP çæ¹å¼ãä¾å¦ï¼è¦ç¡®ä¿ç¦ç¨ register_globalsãå¦æå¯ç¨äº register_globalsï¼å°±å¯è½åä¸äºç²å¿çäºæ
ï¼æ¯å¦ä½¿ç¨ $variable æ¿æ¢ååç GET æ POST å符串ãéè¿ç¦ç¨è¿ä¸ªè®¾ç½®ï¼PHP 强迫æ¨å¨æ£ç¡®çå称空é´ä¸å¼ç¨æ£ç¡®çåéãè¦ä½¿ç¨æ¥èªè¡¨å POST çåéï¼åºè¯¥å¼ç¨ $_POST['variable']ãè¿æ ·å°±ä¸ä¼å°è¿ä¸ªç¹å®åé误ä¼æ cookieãä¼è¯æ GET åéã
è§å 3ï¼å¦æä¸è½ç解å®ï¼å°±ä¸è½ä¿æ¤å®
ä¸äºå¼å人å使ç¨å¥æªçè¯æ³ï¼æè
å°è¯å¥ç»ç»å¾å¾ç´§åï¼å½¢æç®çä½æ¯å«ä¹æ¨¡ç³ç代ç ãè¿ç§æ¹å¼å¯è½æçé«ï¼ä½æ¯å¦ææ¨ä¸ç解代ç æ£å¨åä»ä¹ï¼é£ä¹å°±æ æ³å³å®å¦ä½ä¿æ¤å®ã
ä¾å¦ï¼æ¨å欢ä¸é¢ä¸¤æ®µä»£ç ä¸çåªä¸æ®µï¼
æ¸
å 4. 使代ç 容æå¾å°ä¿æ¤
å¤å¶ä»£ç 代ç å¦ä¸:
<?php
//obfuscated code
$input = (isset($_POST['username']) ? $_POST['username']:â);//unobfuscated code
$input = â;
if (isset($_POST['username'])){
$input = $_POST['username'];
}else{
$input = â;
}
?>
å¨ç¬¬äºä¸ªæ¯è¾æ¸
æ°ç代ç 段ä¸ï¼å¾å®¹æçåº $input æ¯æççµçï¼éè¦è¿è¡æ¸
çï¼ç¶åæè½å®å
¨å°å¤çã
è§å 4ï¼â纵深é²å¾¡â æ¯æ°çæ³å®
æ¬æç¨å°ç¨ç¤ºä¾æ¥è¯´æå¦ä½ä¿æ¤å¨çº¿è¡¨åï¼åæ¶å¨å¤ç表åç PHP 代ç ä¸éç¨å¿
è¦çæªæ½ãåæ ·ï¼å³ä½¿ä½¿ç¨ PHP regex æ¥ç¡®ä¿ GET åéå®å
¨æ¯æ°åçï¼ä»ç¶å¯ä»¥éåæªæ½ç¡®ä¿ SQL æ¥è¯¢ä½¿ç¨è½¬ä¹çç¨æ·è¾å
¥ã
纵深é²å¾¡ä¸åªæ¯ä¸ç§å¥½ææ³ï¼å®å¯ä»¥ç¡®ä¿æ¨ä¸ä¼é·å
¥ä¸¥éç麻ç¦ã
æ¢ç¶å·²ç»è®¨è®ºäºåºæ¬è§åï¼ç°å¨å°±æ¥ç 究第ä¸ç§å¨èï¼SQL 注å
¥æ»å»ã
é²æ¢ SQL 注å
¥æ»å»
å¨ SQL 注å
¥æ»å» ä¸ï¼ç¨æ·éè¿æ纵表åæ GET æ¥è¯¢å符串ï¼å°ä¿¡æ¯æ·»å å°æ°æ®åºæ¥è¯¢ä¸ãä¾å¦ï¼å设æä¸ä¸ªç®åçç»å½æ°æ®åºãè¿ä¸ªæ°æ®åºä¸çæ¯ä¸ªè®°å½é½æä¸ä¸ªç¨æ·åå段åä¸ä¸ªå¯ç å段ãæ建ä¸ä¸ªç»å½è¡¨åï¼è®©ç¨æ·è½å¤ç»å½ã
æ¸
å 5. ç®åçç»å½è¡¨å
å¤å¶ä»£ç 代ç å¦ä¸:
<html>
<head>
<title>Login</title>
</head>
<body>
<form action=âverify.phpâ method=âpostâ>
<p><label for='user'>Username</label>
<input type='text' name='user' id='user'/>
</p>
<p><label for='pw'>Password</label>
<input type='password' name='pw' id='pw'/>
</p>
<p><input type='submit' value='login'/></p>
</form>
</body>
</html>
è¿ä¸ªè¡¨åæ¥åç¨æ·è¾å
¥çç¨æ·ååå¯ç ï¼å¹¶å°ç¨æ·è¾å
¥æ交ç»å为 verify.php çæ件ãå¨è¿ä¸ªæ件ä¸ï¼PHP å¤çæ¥èªç»å½è¡¨åçæ°æ®ï¼å¦ä¸æ示ï¼
æ¸
å 6. ä¸å®å
¨ç PHP 表åå¤ç代ç
å¤å¶ä»£ç 代ç å¦ä¸:
<?php
$okay = 0;
$username = $_POST['user'];
$pw = $_POST['pw'];
$sql = âselect count(*) as ctr from users where username='â.$username.â' and password='â. $pw.â' limit 1â³;$result = mysql_query($sql);
while ($data = mysql_fetch_object($result)){if ($data->ctr == 1){
//they're okay to enter the application!
$okay = 1;
}
}
if ($okay){
$_SESSION['loginokay'] = true;
header(âindex.phpâ);
}else{
header(âlogin.phpâ);
}
?>
è¿ æ®µä»£ç çèµ·æ¥æ²¡é®é¢ï¼å¯¹åï¼ä¸çåå°æç¾ï¼çè³æåï¼ç PHP/MySQL ç«ç¹é½å¨ä½¿ç¨è¿æ ·ç代ç ãå®éå¨åªéï¼å¥½ï¼è®°ä½ âä¸è½ä¿¡ä»»ç¨æ·è¾å
¥âãè¿é没æ对æ¥èªç¨æ·çä»»ä½ä¿¡æ¯è¿è¡è½¬ä¹ï¼å æ¤ä½¿åºç¨ç¨åºå®¹æåå°æ»å»ãå
·ä½æ¥è¯´ï¼å¯è½ä¼åºç°ä»»ä½ç±»åç SQL 注å
¥æ»å»ã
ä¾å¦ï¼å¦æç¨æ·è¾å
¥ foo ä½ä¸ºç¨æ·åï¼è¾å
¥ ' or '1â²='1 ä½ä¸ºå¯ç ï¼é£ä¹å®é
ä¸ä¼å°ä»¥ä¸åç¬¦ä¸²ä¼ éç» PHPï¼ç¶åå°æ¥è¯¢ä¼ éç» MySQLï¼
å¤å¶ä»£ç 代ç å¦ä¸:
<?php
$sql = âselect count(*) as ctr from users where username='foo' and password=â or '1â²='1â² limit 1â³;?>
è¿ä¸ªæ¥è¯¢æ»æ¯è¿å计æ°å¼ 1ï¼å æ¤ PHP ä¼å
许è¿è¡è®¿é®ãéè¿å¨å¯ç å符串çæ«å°¾æ³¨å
¥æäºæ¶æ SQLï¼é»å®¢å°±è½è£
æ®æåæ³çç¨æ·ã
解 å³è¿ä¸ªé®é¢çåæ³æ¯ï¼å° PHP çå
ç½® mysql_real_escape_string() å½æ°ç¨ä½ä»»ä½ç¨æ·è¾å
¥çå
è£
å¨ãè¿ä¸ªå½æ°å¯¹å符串ä¸çå符è¿è¡è½¬ä¹ï¼ä½¿å符串ä¸å¯è½ä¼ éæå·çç¹æ®å符并让 MySQL æ ¹æ®ç¹æ®å符è¿è¡æä½ãæ¸
å 7 å±ç¤ºäºå¸¦è½¬ä¹å¤çç代ç ã
æ¸
å 7. å®å
¨ç PHP 表åå¤ç代ç
å¤å¶ä»£ç 代ç å¦ä¸:
<?php
$okay = 0;
$username = $_POST['user'];
$pw = $_POST['pw'];
$sql = âselect count(*) as ctr from users where username='â.mysql_real_escape_string($username).â' and password='â. mysql_real_escape_string($pw).â' limit 1â³;$result = mysql_query($sql);
while ($data = mysql_fetch_object($result)){if ($data->ctr == 1){
//they're okay to enter the application!
$okay = 1;
}
}
if ($okay){
$_SESSION['loginokay'] = true;
header(âindex.phpâ);
}else{
header(âlogin.phpâ);
}
?>
ä½¿ç¨ mysql_real_escape_string() ä½ä¸ºç¨æ·è¾å
¥çå
è£
å¨ï¼å°±å¯ä»¥é¿å
ç¨æ·è¾å
¥ä¸çä»»ä½æ¶æ SQL 注å
¥ãå¦æç¨æ·å°è¯éè¿ SQL 注å
¥ä¼ éç¸å½¢çå¯ç ï¼é£ä¹ä¼å°ä»¥ä¸æ¥è¯¢ä¼ éç»æ°æ®åºï¼
select count(*) as ctr from users where username='foo' and password='\' or \'1\'=\'1â² limit 1â³æ°æ®åºä¸æ²¡æä»»ä½ä¸è¥¿ä¸è¿æ ·çå¯ç å¹é
ãä»
ä»
éç¨ä¸ä¸ªç®åçæ¥éª¤ï¼å°±å µä½äº Web åºç¨ç¨åºä¸çä¸ä¸ªå¤§æ¼æ´ãè¿éå¾åºçç»éªæ¯ï¼æ»æ¯åºè¯¥å¯¹ SQL æ¥è¯¢çç¨æ·è¾å
¥è¿è¡è½¬ä¹ã
ä½æ¯ï¼è¿æå 个å®å
¨æ¼æ´éè¦å µä½ãä¸ä¸é¡¹æ¯æ纵 GET åéã
é²æ¢ç¨æ·æ纵 GET åé
å¨åä¸èä¸ï¼é²æ¢äºç¨æ·ä½¿ç¨ç¸å½¢çå¯ç è¿è¡ç»å½ãå¦ææ¨å¾èªæï¼åºè¯¥åºç¨æ¨å¦å°çæ¹æ³ï¼ç¡®ä¿å¯¹ SQL è¯å¥çææç¨æ·è¾å
¥è¿è¡è½¬ä¹ã
ä½ æ¯ï¼ç¨æ·ç°å¨å·²ç»å®å
¨å°ç»å½äºãç¨æ·æ¥æææçå¯ç ï¼å¹¶ä¸æå³çä»å°æç
§è§åè¡äº ââ ä»æå¾å¤æºä¼è½å¤é ææ害ãä¾å¦ï¼åºç¨ç¨åºå¯è½å
许ç¨æ·æ¥çç¹æ®çå
容ãææé¾æ¥æå template.php?pid=33 æ template.php?pid=321 è¿æ ·çä½ç½®ãURL ä¸é®å·åé¢çé¨å称为æ¥è¯¢å符串ãå 为æ¥è¯¢å符串ç´æ¥æ¾å¨ URL ä¸ï¼æ以ä¹ç§°ä¸º GET æ¥è¯¢å符串ã
å¨ PHP ä¸ï¼å¦æç¦ç¨äº register_globalsï¼é£ä¹å¯ä»¥ç¨ $_GET['pid'] 访é®è¿ä¸ªå符串ãå¨ template.php 页é¢ä¸ï¼å¯è½ä¼æ§è¡ä¸æ¸
å 8 ç¸ä¼¼çæä½ã
æ¸
å 8. ç¤ºä¾ template.php
å¤å¶ä»£ç 代ç å¦ä¸:
<?php
$pid = $_GET['pid'];
//we create an object of a fictional class Page$obj = new Page;
$content = $obj->fetchPage($pid);
//and now we have a bunch of PHP that displays the page?>
è¿ éæä»ä¹éåï¼é¦å
ï¼è¿ééå«å°ç¸ä¿¡æ¥èªæµè§å¨ç GET åé pid æ¯å®å
¨çãè¿ä¼æä¹æ ·å¢ï¼å¤§å¤æ°ç¨æ·æ²¡é£ä¹èªæï¼æ æ³æé åºè¯ä¹æ»å»ãä½æ¯ï¼å¦æä»ä»¬æ³¨æå°æµè§å¨ç URL ä½ç½®åä¸ç pid=33ï¼å°±å¯è½å¼å§æ£ä¹±ãå¦æä»ä»¬è¾å
¥å¦ä¸ä¸ªæ°åï¼é£ä¹å¯è½æ²¡é®é¢ï¼ä½æ¯å¦æè¾å
¥å«çä¸è¥¿ï¼æ¯å¦è¾å
¥ SQL å½ä»¤ææ个æ件çå称ï¼æ¯å¦ /etc/passwdï¼ï¼æè
æå«çæ¶ä½å§ï¼æ¯å¦è¾å
¥é¿è¾¾ 3,000 个å符çæ°å¼ï¼é£ä¹ä¼åçä»ä¹å¢ï¼
å¨è¿ç§æ
åµä¸ï¼è¦è®°ä½åºæ¬è§åï¼ä¸è¦ä¿¡ä»»ç¨æ·è¾å
¥ãåºç¨ç¨åºå¼å人åç¥é template.php æ¥åç个人æ è¯ç¬¦ï¼PIDï¼åºè¯¥æ¯æ°åï¼æ以å¯ä»¥ä½¿ç¨ PHP ç is_numeric()å½æ°ç¡®ä¿ä¸æ¥åéæ°åç PIDï¼å¦ä¸æ示ï¼
æ¸
å 9. ä½¿ç¨ is_numeric() æ¥éå¶ GET åéå¤å¶ä»£ç 代ç å¦ä¸:
<?php
$pid = $_GET['pid'];
if (is_numeric($pid)){
//we create an object of a fictional class Page$obj = new Page;
$content = $obj->fetchPage($pid);
//and now we have a bunch of PHP that displays the page}else{
//didn't pass the is_numeric() test, do something else!
}
?>
è¿ä¸ªæ¹æ³ä¼¼ä¹æ¯ææçï¼ä½æ¯ä»¥ä¸è¿äºè¾å
¥é½è½å¤è½»æ¾å°éè¿ is_numeric() çæ£æ¥ï¼
100 ï¼ææï¼
100.1 ï¼ä¸åºè¯¥æå°æ°ä½ï¼
+0123.45e6 ï¼ç§å¦è®¡æ°æ³ ââ ä¸å¥½ï¼
0xff33669f ï¼åå
è¿å¶ ââ å±é©ï¼å±é©ï¼ï¼é£ä¹ï¼æå®å
¨æè¯ç PHP å¼å人ååºè¯¥æä¹åå¢ï¼å¤å¹´çç»éªè¡¨æï¼æ好çåæ³æ¯ä½¿ç¨æ£å表达å¼æ¥ç¡®ä¿æ´ä¸ª GET åéç±æ°åç»æï¼å¦ä¸æ示ï¼
æ¸
å 10. 使ç¨æ£å表达å¼éå¶ GET åé
å¤å¶ä»£ç 代ç å¦ä¸:
<?php
$pid = $_GET['pid'];
if (strlen($pid)){
if (!ereg(â^[0-9]+$â,$pid)){
//do something appropriate, like maybe logging them out or sending them back to home page}
}else{
//empty $pid, so send them back to the home page}
//we create an object of a fictional class Page, which is now//moderately protected from evil user input$obj = new Page;
$content = $obj->fetchPage($pid);
//and now we have a bunch of PHP that displays the page?>
é è¦åçåªæ¯ä½¿ç¨ strlen() æ£æ¥åéçé¿åº¦æ¯å¦éé¶ï¼å¦ææ¯ï¼å°±ä½¿ç¨ä¸ä¸ªå
¨æ°åæ£å表达å¼æ¥ç¡®ä¿æ°æ®å
ç´ æ¯ææçãå¦æ PID å
å«åæ¯ãæ线ãç¹å·æä»»ä½ä¸åå
è¿å¶ç¸ä¼¼çå
容ï¼é£ä¹è¿ä¸ªä¾ç¨æè·å®å¹¶å°é¡µé¢ä»ç¨æ·æ´»å¨ä¸å±è½ãå¦æçä¸ä¸ Page ç±»å¹åçæ
åµï¼å°±ä¼çå°æå®å
¨æè¯ç PHP å¼å人åå·²ç»å¯¹ç¨æ·è¾å
¥ $pid è¿è¡äºè½¬ä¹ï¼ä»èä¿æ¤äº fetchPage() æ¹æ³ï¼å¦ä¸æ示ï¼
æ¸
å 11. 对 fetchPage() æ¹æ³è¿è¡è½¬ä¹
å¤å¶ä»£ç 代ç å¦ä¸:
<?php
class Page{
function fetchPage($pid){
$sql = âselect pid,title,desc,kw,content,status from page where pid='â.mysql_real_escape_string($pid).â'â;}
}
?>
æ¨å¯è½ä¼é®ï¼âæ¢ç¶å·²ç»ç¡®ä¿ PID æ¯æ°åï¼é£ä¹ä¸ºä»ä¹è¿è¦è¿è¡è½¬ä¹ï¼â å 为ä¸ç¥éå¨å¤å°ä¸åçä¸ä¸æåæ
åµä¸ä¼ä½¿ç¨ fetchPage() æ¹æ³ãå¿
é¡»å¨è°ç¨è¿ä¸ªæ¹æ³çææå°æ¹è¿è¡ä¿æ¤ï¼èæ¹æ³ä¸ç转ä¹ä½ç°äºçºµæ·±é²å¾¡çæä¹ã
å¦ æç¨æ·å°è¯è¾å
¥é常é¿çæ°å¼ï¼æ¯å¦é¿è¾¾ 1000 个å符ï¼è¯å¾åèµ·ç¼å²åºæº¢åºæ»å»ï¼é£ä¹ä¼åçä»ä¹å¢ï¼ä¸ä¸èæ´è¯¦ç»å°è®¨è®ºè¿ä¸ªé®é¢ï¼ä½æ¯ç®åå¯ä»¥æ·»å å¦ä¸ä¸ªæ£æ¥ï¼ç¡®ä¿è¾å
¥ç PID å
·ææ£ç¡®çé¿åº¦ãæ¨ç¥éæ°æ®åºç pid å段çæ大é¿åº¦æ¯ 5 ä½ï¼æ以å¯ä»¥æ·»å ä¸é¢çæ£æ¥ã
æ¸
å 12. 使ç¨æ£å表达å¼åé¿åº¦æ£æ¥æ¥éå¶ GET åéå¤å¶ä»£ç 代ç å¦ä¸:
<?php
$pid = $_GET['pid'];
if (strlen($pid)){
if (!ereg(â^[0-9]+$â,$pid) && strlen($pid) > 5){//do something appropriate, like maybe logging them out or sending them back to home page}
} else {
//empty $pid, so send them back to the home page}
//we create an object of a fictional class Page, which is now//even more protected from evil user input$obj = new Page;
$content = $obj->fetchPage($pid);
//and now we have a bunch of PHP that displays the page?>
ç°å¨ï¼ä»»ä½äººé½æ æ³å¨æ°æ®åºåºç¨ç¨åºä¸å¡è¿ä¸ä¸ª 5,000 ä½çæ°å¼ ââ è³å°å¨æ¶å GET å符串çå°æ¹ä¸ä¼æè¿ç§æ
åµãæ³åä¸ä¸é»å®¢å¨è¯å¾çªç ´æ¨çåºç¨ç¨åºèéå°æ«ææ¶å¬çå齿çæ ·åå§ï¼èä¸å 为å
³éäºé误æ¥åï¼é»å®¢æ´é¾è¿è¡ä¾¦å¯ã
ç¼å²åºæº¢åºæ»å»
ç¼å²åºæº¢åºæ»å» è¯å¾ä½¿ PHP åºç¨ç¨åºä¸ï¼æè
æ´ç²¾ç¡®å°è¯´ï¼å¨ Apache æåºå±æä½ç³»ç»ä¸ï¼çå
ååé
ç¼å²åºåç溢åºã请记ä½ï¼æ¨å¯è½æ¯ä½¿ç¨ PHP è¿æ ·çé«çº§è¯è¨æ¥ç¼å Web åºç¨ç¨åºï¼ä½æ¯æç»è¿æ¯è¦è°ç¨ Cï¼å¨ Apache çæ
åµä¸ï¼ãä¸å¤§å¤æ°ä½çº§è¯è¨ä¸æ ·ï¼C 对äºå
ååé
æä¸¥æ ¼çè§åã
ç¼å²åºæº¢åºæ»å»åç¼å²åºåé大éæ°æ®ï¼ä½¿é¨åæ°æ®æº¢åºå°ç¸é»çå
åç¼å²åºï¼ä»èç ´åç¼å²åºæè
éåé»è¾ãè¿æ ·å°±è½å¤é ææç»æå¡ãç ´åæ°æ®æè
å¨è¿ç¨æå¡å¨ä¸æ§è¡æ¶æ代ç ã
é²æ¢ç¼å²åºæº¢åºæ»å»çæä¸æ¹æ³æ¯æ£æ¥ææç¨æ·è¾å
¥çé¿åº¦ãä¾å¦ï¼å¦ææä¸ä¸ªè¡¨åå
ç´ è¦æ±è¾å
¥ç¨æ·çååï¼é£ä¹å¨è¿ä¸ªåä¸æ·»å å¼ä¸º 40 ç maxlength å±æ§ï¼å¹¶å¨åç«¯ä½¿ç¨ substr() è¿è¡æ£æ¥ãæ¸
å 13 ç»åºè¡¨åå PHP 代ç çç®ç示ä¾ã
温馨提示:答案为网友推荐,仅供参考