php smarty °²×° ¡¢ÅäÖá¢Ê¹Óà ¼°»º´æcacheµÄÅäÖÃʹÓÃ
cache ʹÓãº
cacheÅäÖãº
$smarty->cache_dir = "/caches/"; //»º´æÄ¿Â¼
$smarty->caching = true; //¿ªÆô»º´æ,ΪflaseµÄʱºî»º´æÎÞЧ
$smarty->cache_lifetime = 60; //»º´æÊ±¼ä
cacheÇå³ýºÍʹÓãº
$smarty->display('cache.tpl', cache_id); //´´½¨´øIDµÄ»º´æ
cache.tpl //Ä£°åÎļþ
$smarty->clear_all_cache(); //Çå³ýËùÓлº´æ
$smarty->clear_cache('index.htm'); //Çå³ýindex.tplµÄ»º´æ
$smarty->clear_cache('index.htm',cache_id); //Çå³ýÖ¸¶¨idµÄ»º´æ
smarty °²×°ÅäÖà ˵Ã÷£º
ÏÂÔØsmarty½âѹ ½«libsĿ¼ copyµ½ÏîÄ¿Ö÷Ŀ¼Ï£¬ÖÁÉÙ½¨Á¢ÈçÏÂÈçÏÂÎļþ¼Ð£ºtemplates templates_c configs cache
index.php
<?php
include("libs/Smarty.class.php");
$smarty = new Smarty;
$smarty->template_dir = './templates/';
$smarty->compile_dir = './templates_c/';
$smarty->config_dir = './configs/';
$smarty->cache_dir = './cache/';
$smarty->caching = true;
$smarty->cache_lifetime = 60;
$smarty->left_delimiter = "<{";
$smarty->right_delimiter = "}>";
$smarty->assign("title", "À¬»ø");
$smarty->assign("content","²âÊÔÓõÄÍøÒ³ÄÚÈÝ00");
$smarty->display("index.tpl",cache_id);
?>
index.tplÄ£°åÎļþ
<html>
¡¡¡¡<head>
¡¡¡¡<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
¡¡¡¡<title><{$title}></title>
¡¡¡¡</head>
¡¡¡¡<body>
¡¡¡¡<{$content}>
¡¡¡¡</body>
¡¡¡¡</html>
Ïà¹ØÎĵµ£º
php»ù´¡Ñ§Ï°ÒѾ²î²»¶àÁË,µ«ÊÇΪ¼ìÑé×Ô¼ºµÄÑ§Ï°ÕÆÎÕÇé¿ö,°Ñphp»ù´¡ÖªÊ¶»Ø¹Ë¸´Ï°ÁËÒ»ÏÂ
µÚÒ»¸öPHP³ÌÐò
<?php
echo "Hello World!";
?>
1 ×¢ÊÍ
1.1¶àÐÐ
/*
xxxx
*/
1.2µ¥ÐÐ
//xxxxx
2. ¸³Öµ
$a = 'test';
2.1 ¼ì²é±äÁ¿ÊÇ·ñÒÑÉùÃ÷
isset($a)
2.2 ÊͷűäÁ¿
unset($a);
2.3 ¾² ......
ÏÖÔÚÖ÷Á÷µÄÍøÕ¾¿ª·¢ÓïÑÔÎÞÍâºõasp¡¢php¡¢asp.net¡¢jspµÈ¡£
ÍøÒ³´Ó¿ªÊ¼¼òµ¥µÄhmtlµ½¸´ÔӵķþÎñÓïÑÔ£¬×ß¹ýÁË10¶à¸öÄêÍ·£¬¸÷ÖÖ¼¼Êõ²ã³ö²»Çµ¥¸öµÄÖ÷Á÷¼¼ÊõÒ²ÔÚ²»¶Ï·Ðµİ汾£¬ÏÖÔÚ·ÖÎöϸ÷ÖÖÓïÑÔµÄÇø±ð¡¢ÓÅÊÆ¡¢ÁÓÊÆ¡¢¿ª·¢×¢ÒâÊÂÏ
HTML:µ±È»ÕâÊÇÍøÒ³×î»ù±¾µÄÓïÑÔ,ÿһ¸ö·þÎñÆ÷ÓïÑÔ¶¼ÐèÒªËüµÄÖ§³Ö,Ҫѧϰ,Õâ¸ö¿Ï¶¨ÊÇ¿ªÊ¼ ......
ÔÚÍùPHP SessionÀïÃæ±£´æÐÅϢ֮ǰ£¬ÐèÒªÊ×ÏÈʹÓÃsession_start()º¯ÊýÀ´Æô¶¯session,
Õâ¸öº¯Êý±ØÐëÔÚ<html>±êǩ֮ǰµ÷ÓᣴúÂëÈçÏ£º
<?php session_start(); ?>
<html>
<body>
</body>
</html>
ÔÚSessionÆô¶¯ÒԺ󣬿ÉÒÔʹÓÃPHP $_SESSION±äÁ¿À´»ñÈ¡ºÍÉèÖÃsession±äÁ¿£¬ÊµÀý´ú ......
ÓÃPHPʵÏÖ¼òµ¥µÄÊý¾Ýץȡ
·½·¨Ò»£º
<?php
$urlstr = file_get_contents("http://www.baidu.com");
$urlstr = htmlspecialchars($urlstr);
print_r($urlstr);
?>
·½·¨¶þ£º£¨ÐèÒª´ò¿ªcurlÀ©Õ¹£©
×¢Ò⣺´ò¿ªcurlÀ©Õ¹Ê±£¬Ò»¶¨Òª¿´¿ ......