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
$file = fopen('your file path','r');
while(!feof($file)){ //µ±Ã»ÓжÁÈ¡µ½Îļþ½á⣬¼ÌÐøÑ»·¶ÁÈ¡²Ù×÷
$line = fgets($file); //¶ÁÈ¡µ½Ò»ÐеÄÄÚÈÝ
echo $line.'<br/>';
}
fclose($file) ......
Èí¼þÀë²»¿ªÊý¾Ý¿â£¬¶øPHP×î³£ÓõÄÊý¾Ý¿âÊÇMySQL¡£MySQLÊý¾Ý¿â·Ö·þÎñ¶ËºÍ¿Í»§¶Ë¡£
MySQL·þÎñ¶ËµÄ°²×°£º
(1)µã»÷MySQL°²×°°ü£¨´Ë´¦µÄ°²×°³ÌÐòΪmysql-5.0.18-win32.zip)
(2) ĬÈÏÊÇTypical,Èç¹ûÏëÐ޸ݲװ·¾¶µÄ»°Ò²¿ÉÒÔÑ¡Ôñcustom.
×¢Òâ:°²×°mysqlµÄ·¾¶ÖÐ,²»Äܺ¬ÓÐÖÐÎÄ!
(3)µã»÷intall¿ªÊ¼°²×°
(4)Ìø¹ý×¢²á
(5 ......
ÎÊÌ⣺
ÄãÏë´´½¨Ò»¸ö¶ÔÏ󣬲¢ÔÚÆäÖÐÌí¼ÓһЩÊôÐÔ£¬µ«ÊÇÄãÈ´²»Ïë°ÑËü×÷Ϊһ¸öÃ÷È·µÄÀàÕýʽµØ¶¨ÒåËü¡£ÕâÒ»µãÔÚһЩÇé¿öÏÂÊÇÏ൱ÓÐÓõģ¬ÀýÈçµ±ÄãÐèÒª¶¨ÒåÒ»¸ö·½·¨À´·µ»Ø´øÓÐijЩÊôÐÔ£¨²»È·¶¨µÄ£©µÄ¶ÔÏóʱ£¬¾ÍÈçͬ´Ómysql_fetch_object( ) »òÕß imap_header( )µÄʹÓÃÒ»Ñù¡£
һάÊý×é,ÎÒÏÖÔÚÌØ±ðϲ»¶°ÑËüд³É¶ÔÏó,ÒòΪ¼üÅÌ´ ......
<?php
function toFixLen($str,$len){ //¹Ì¶¨³¤¶È×Ö·û´®µÄ½ØÈ¡
if($len>=strlen($str)||!$len) return $str;
$len-=3;
  ......
²Î¿¼×ÊÁÏ£º
1.
2. http://www.phpeclipse.com/wiki/Howto/XDebugAndPHPEclipse
1.ÏÂÔØXDebug http://xdebug.org/download.php
Ñ¡ÔñÓÚPHP°æ±¾Ïà¶ÔÓ¦µÄµÄ 5.2 VC6 (32 bit) ÏÂÔØ£¬¸ÄÃû³Éphp_xdebug.dllºó¸´ÖƵ½E:/APMServ5.2.6/PHP/ext/ÖÐ
2£® ÔÚphp.iniÖÐÌí¼ÓÒÔÏÂÄÚÈÝ£¬²¢½«zendµÄÆäËûÓ¦Óùصô£¨×¢Ê͵ôÆäËûzend_extens ......