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

PHP smartyѧϰ

phpÎļþ
<?php
mysql_connect("localhost","","");
mysql_query("set names 'gb2312'");
mysql_select_db("shop");
$sqlstr="select * from goods";
require 'smarty/libs/Smarty.class.php';
$smarty = new Smarty;//ÉèÖø÷¸öĿ¼µÄ·¾¶£¬ÕâÀïÊǰ²×°µÄÖØµã
$smarty->template_dir ="smarty/templates/templates";//ÔÚÏîÄ¿¸ùĿ¼ÏÂÃæ½¨´ËÎļþ¼Ð
$smarty->compile_dir ="smarty/templates/templates_c";
$smarty->config_dir = "smarty/templates/config";
$smarty->cache_dir ="smarty/templates/cache";
//smartyÄ£°åÓиßËÙ»º´æµÄ¹¦ÄÜ£¬Èç¹ûÕâÀïÊÇtrueµÄ»°¼´´ò¿ªcaching£¬µ«ÊÇ»áÔì³ÉÍøÒ³²»Á¢¼´¸üеÄÎÊÌ⣬µ±È»Ò²¿ÉÒÔͨ¹ýÆäËûµÄ°ì·¨½â¾ö
$smarty->caching = false;
$exec=mysql_query($sqlstr);
$rs=mysql_fetch_object($exec);
$arr=array();
$thenumber=0;
while($rs)
{
 $arr2=array();
 $arr2[0]=$rs->goodsname;
 $arr2[1]=$rs->price;
 $arr[$thenumber]=$arr2;
 $rs=mysql_fetch_object($exec);
 $thenumber=$thenumber+1;
}
$smarty->assign("guests",$arr); //$arrΪ¶þάÊý×飬½«Ëü¸³¸øÄ£°åÖеÄ$guest±äÁ¿
$smarty->display('index.tpl');
?>
 tplÎļþ
<!DOCTYPE HTML PUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<metahttp-equiv="Content-Type" content="text/html;charset=gb2312">
<title>Smarty</title></head>
<body>
<table border="1">
{foreach from = $guests item=guest} //itemΪѡÏîÈ¡Ãû
     <tr>
     <td>{$guest.0}</td> //$guestÓëitemµÄÖµÏàͬ£¬0Óë$arr2[0]Ïàͬ¡£
     <td>{$guest.1}</td>
     </tr>
{/foreach}
</table>
</body>
</html>


Ïà¹ØÎĵµ£º

PhpÊý×é

 
1,¶¨Î»Êý×飺
bool in_array ( mixed needle,array haystack[,bool strict]) ²éÕÒÖ¸¶¨ÔªËØ£»
array array_keys (arraqy input [, mixed search_value]) ·µ»Ø¼üÖµ×é³ÉµÄÊý×飻
bool array_key_exists(mixed key,array search) ÅжϼüÖµÊÇ·ñΪָ¶¨µÄ¼üÖµ£»
array array_values (array input) ·µ»ØÊý×éÖеÄÔªËØÖµ£ ......

PHPÊý×麯Êý


½«Ò»¸ö1άÊý×é·Ö¸î³É2άÊý×é array_chunk()
$input_array = array('a', 'b', 'c', 'd', 'e');
print_r(array_chunk($input_array, 2));

±È½Ï2¸öÊý×飬array_diff_assoc£¨£©»òÕßarray_diff£¨£©£¬Èç¹û·µ»ØÖµÎª¿Õ£¬±íʾÁ½¸öÊý×éÏàͬ£¬·ñÔò¾Í²»Í¬¡£
ÓÃÒ»¸öº¯ÊýÀ´¹ýÂËÊý×éÖеÄÊýÖµarray_filter()


functi ......

phpÓëmysqlÔ­×Ó²Ù×÷

 ºÜ¾Ã¶¼Ã»ÓÐдһÏÂѧϰÈÕÖ¾ÁË,¶¼²»ÖªµÀ×î½üÔÚæʲô,ͻȻ¾õµÃ×Ô¼ºÓ¦¸ÃдµãʲôÉÏÈ¥.
    Êý¾Ý¿âµÄÔ­×Ó²Ù×÷ÊÇÁ½Èý¸öÔÂǰѧµÄ¶«Î÷ÁË,½ñÌìͻȻÓÖÓõ½ÁË,Òò´Ë½ñÌì±ØÐëµÃ½«Æä¼Ç¼ÏÂÀ´,·ñÔòÏ´ÎÓÖÒªÖØÐÂËÑË÷ÁË.
    Ô­×Ó²Ù×÷³£Óõķ½·¨¾ÍÊÇͨ¹ýÊý¾Ý»Ø¹öÀ´ÊµÏÖ,Óà PHP À´ÊµÏÖÊý¾Ý¿â»Ø¹ö ......

PHP»º´æ¼¼ÊõÏê̸

Ò»¡¢ÒýÂÛ
PHP,Ò»ÃÅ×î½ü¼¸ÄêÐËÆðµÄwebÉè¼Æ½Å±¾ÓïÑÔ,ÓÉÓÚËüµÄÇ¿´óºÍ¿ÉÉìËõÐÔ,½ü¼¸ÄêÀ´µÃµ½³¤×ãµÄ·¢Õ¹,phpÏà±È´«Í³µÄaspÍøÕ¾,ÔÚËÙ¶ÈÉÏÓоø¶ÔµÄÓÅÊÆ,Ïëmssqlת6ÍòÌõÊý¾ÝphpÈçÐèÒª40Ãë,asp²»ÏÂ2·ÖÖÓ.µ«ÊÇ,ÓÉÓÚÍøÕ¾µÄÊý¾ÝÔ½À´Ô½¶à,ÎÒÃÇ¿ÊÇóÄܸü¿ìËٵĵ÷ÓÃÊý¾Ý,²»±ØÒªÃ¿´Î¶¼´ÓÊý¾Ý¿âµô,ÎÒÃÇ¿ÉÒÔ´ÓÆäËûµÄµØ·½,±È·½Ò»¸öÎļþ,»òÕßij¸ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ