唠叨看看呀,怎么使用啊?不过不懂得灵活运用也不行啊 ini_set在此作什么? 如下代码是可以运行的,可是用d:/....这样的路径是不是不太好啊? <? ini_set('include_path',realpath('./include')); require_once "include/class.smarttemplate.php"; $_CONFIG = array( smarttemplate_compiled => "d:/apache/htdocs/temp", smarttemplate_cache => "d:/apache/htdocs/cache", cache_lifetime => 600, template_dir => "d:/apache/htdocs/templates/default" ); $page = new SmartTemplate("uppercase.html"); $page->assign('TEXT', 'Simple Demo Text.'); $page->output(); ?>如果只用目录名则提示:Warning: output(temp/uppercase_html.php) [function.output]: failed to create stream: No such file or directory in d:\apache\htdocs\include\class.smarttemplate.php on line 278Warning: output(temp/uppercase_html.php) [function.output]: failed to create stream: No such file or directory in d:\apache\htdocs\include\class.smarttemplate.php on line 278Warning: output() [function.output]: Failed opening 'temp/uppercase_html.php' for inclusion (include_path='d:\apache\htdocs\include') in d:\apache\htdocs\include\class.smarttemplate.php on line 278
你看一下smarttemplate的安装说明就知道了,class.smarttemplate.php
class.smartparser.php
class.smartdebug.php
smarttemplate_extensions必须在include_path设置范围下,比如 include_path = ".;c:/php/include"
那么这三个文件和一个目录就必须在当前目录或c:/php/include中。为此,安装说明是建议你拷贝到include目录的。这样在任何目录下都可使用这个模板类。
除非你自己修改文件中的路径代码temp、cache目录最好是绝对路径,这样就不必要到处建目录了
和我曾经一样的问题,呵呵。
写一段实例吧?
$_CONFIG['smarttemplate_compiled'] = SMART_TEMP_DIR;
$_CONFIG['smarttemplate_cache'] = SMART_CACHE_DIR;
$_CONFIG['cache_lifetime'] = SMART_CACHE_LIFETIME;
$_CONFIG['template_dir'] = SMART_TEMPLATE_DIR;
$_CONFIG['reuse_code'] = SMART_REUSE_CODE;
这个是放在class.smarttemplate.php中class SmartTemplate{.....之前的。另外的配置文件里
DEFINE ('ROOT_PATH','D:/webserver/');
DEFINE ('SMART_REUSE_CODE', false);
DEFINE ('SMART_TEMPLATE_DIR',ROOT_PATH.'templates/default/');
DEFINE ('SMART_TEMP_DIR',ROOT_PATH.'temp/');
DEFINE ('SMART_CACHE_DIR',ROOT_PATH.'cache/');
DEFINE ('SMART_CACHE_LIFETIME', 864000);
DEFINE ('USERCACHE',FALSE);
DEFINE ('EXT','.html');
<?php
include_once "smarttemplate_extensions/smarttemplate_extension_uppercase.php";?>
按照你的目录结构可以<?
ini_set('include_path',realpath('./include'));
require_once "class.smarttemplate.php";
$_CONFIG = array(
smarttemplate_compiled => "temp",
smarttemplate_cache => "cache",
cache_lifetime => 600,
template_dir => "templates/default"
);
....
ini_set在此作什么?
如下代码是可以运行的,可是用d:/....这样的路径是不是不太好啊?
<?
ini_set('include_path',realpath('./include'));
require_once "include/class.smarttemplate.php";
$_CONFIG = array(
smarttemplate_compiled => "d:/apache/htdocs/temp",
smarttemplate_cache => "d:/apache/htdocs/cache",
cache_lifetime => 600,
template_dir => "d:/apache/htdocs/templates/default"
);
$page = new SmartTemplate("uppercase.html");
$page->assign('TEXT', 'Simple Demo Text.');
$page->output();
?>如果只用目录名则提示:Warning: output(temp/uppercase_html.php) [function.output]: failed to create stream: No such file or directory in d:\apache\htdocs\include\class.smarttemplate.php on line 278Warning: output(temp/uppercase_html.php) [function.output]: failed to create stream: No such file or directory in d:\apache\htdocs\include\class.smarttemplate.php on line 278Warning: output() [function.output]: Failed opening 'temp/uppercase_html.php' for inclusion (include_path='d:\apache\htdocs\include') in d:\apache\htdocs\include\class.smarttemplate.php on line 278
我发现realpath真是神奇啊,有了自定义的include_path后,
只要是require 'xx.php';
都是指包含这个include_path的xx.php文件,真是神奇啊