Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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ʵÏÖÎļþµÄ¶ÁºÍд¹¦ÄÜ

½øÐÐÎļþµÄ¶ÁºÍд£¬ÏÈ´ò¿ªÒ»¸öÎļþ£¬È»ºó¿ªÊ¼¶Á»òÕßдÎļþ£¬×îºóÔÙ¹ØÏµÕâ¸öÎļþ×ÊÔ´¡£
È磬ÎļþµÄ¶Á²Ù×÷£º
<?php
$file = fopen('your file path','r');
while(!feof($file)){ //µ±Ã»ÓжÁÈ¡µ½Îļþ½á⣬¼ÌÐøÑ­»·¶ÁÈ¡²Ù×÷
$line = fgets($file); //¶ÁÈ¡µ½Ò»ÐеÄÄÚÈÝ
echo $line.'<br/>';
}
fclose($file) ......

phpÃæÏò¶ÔÏóµÄ»ù´¡

£±,ÀàµÄ½á¹¹ÉùÃ÷·½Ê½£º
¡¡¡¡ class ÀàÃû {
               //ÀàÌå
      }
£²£¬ÊôÐԺͷ½·¨µÄ¶¨Ò壻
¡¡¡¡Ê¹Óù¹Ô캯Êý£º
¡¡¡¡Ê¹ÓÃÎö¹¹º¯Êý£º
¡¡¡¡ÀàµÄʵÀý»¯£º
£³,¿ØÖÆ·ÃÎÊȨÏÞ£ºpublic , private protected;
£´ ......

phpÖУ¬¹ØÓÚÕû³ýµÄ3¸öº¯Êý2008

phpÖУ¬¹ØÓÚÕû³ýµÄ3¸öº¯Êý
2008-10-23 23:25
Ceil: ¼ÆËã´óÓÚÖ¸¶¨ÊýµÄ×îСÕûÊý¡£
Floor: ¼ÆËãСÓÚÖ¸¶¨ÊýµÄ×î´óÕûÊý¡£
round: ËÄÉáÎåÈë¡£
¸ù¾ÝÐèҪѡÓÃ
<?php
$a=20;
$b = 6;
echo ($a/$b)."<br>"; //out 3.3333333333333
echo ceil($a/$b)."<br>"; //out 4
echo floor($a/$b)."<br> ......

PHPɾ³ý·Ç¿ÕĿ¼º¯Êý

<?php
function remove_directory($dir) {
  if ($handle = opendir("$dir")) {
   while (false !== ($item = readdir($handle))) {
     if ($item != "." && $item != "..") {
      ......

php°²×°³ÌÐòÖÆ×÷¼Ç¼

php°²×°³ÌÐòÔ­Àí£º
   ÆäʵPHP³ÌÐòµÄ°²×°Ô­ÀíÎ޷ǾÍÊǽ«Êý¾Ý¿â½á¹¹ºÍÄÚÈݵ¼Èëµ½ÏàÓ¦µÄÊý¾Ý¿âÖУ¬´ÓÕâ¸ö¹ý³ÌÖÐÖØÐÂÅäÖÃÁ¬½ÓÊý¾Ý¿âµÄ²ÎÊýºÍÎļþ£¬ÎªÁ˱£Ö¤²»±»±ðÈ˶ñÒâʹÓð²×°Îļþ£¬µ±°²×°Íê³ÉºóÐèÒªÐ޸ݲװÎļþ¡£
²½Ö裺
¼ì²éĿ¼»òÎļþµÄȨÏÞ
Ð޸ĻòÌî¼ÓÅäÖÃÎļþ
¼ì²éÅäÖÃÎļþÕýÈ·ÐÔ
µ¼ÈëÊý¾Ý¿â
Ëø¶¨»òÉ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ