免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: wenhuaixiang
打印 上一主题 下一主题

PHP5用smarttemplate的时候总是报错误啊~ [复制链接]

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
21 [报告]
发表于 2006-08-01 09:04 |只看该作者
原帖由 wenhuaixiang 于 2006-8-1 08:49 发表
我的环境是RH AS 4+PHP5+smarttemplate-1.2.1+APache2
代码如下:
<HTML>;
<H3>;{TITLE}</H3>;
</HTML>;


<?php

    require_once "/var/smartte ...


Debug Strict (PHP 5): /SmartTemplate/smarttemplate-1.2.1/class.smarttemplateparser.php line 20 - var: Deprecated. Please use the public/private/protected modifiers

Zend建议采用PHP5的标准格式,但是我们的代码在PHP4和PHP5都通用,所以这里使用的var。
你可以这么做:
打开这个文件,最前面的变量定义部分,依据:
@access
修改为private或者public

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
22 [报告]
发表于 2006-08-01 09:07 |只看该作者
另外:
在第12楼,我们才知道你的错误提示到底是什么!

在第19楼,我们才知道,你使用的Zend调试器的时候的提示!

你为什么不在第1楼就告诉我们呢?

Zend调试器的检查可能较为严格。

我不用,所以你自己可以看Zend调试器的手册和说明,把这样子的检查的级别调低。

或者干脆久不用Zend调试器。

论坛徽章:
0
23 [报告]
发表于 2006-08-01 09:15 |只看该作者
什么意思?我的代码写错了?还有就是我的php是5.1.4
就是你提供下载的官方网站下下来的就三个.php的文件下面是其中之一。我的另外两个文件还用改什么吗?
<?php
        /**
        * SmartTemplate Class
        *
        * 'Compiles' HTML-Templates to PHP Code
        *
        *
        * Usage Example I:
        *
        * $page = new SmartTemplate( "template.html" );
        * $page->assign( 'TITLE',  'TemplateDemo - Userlist' );
        * $page->assign( 'user',   DB_read_all( 'select * from ris_user' ) );
        * $page->output();
        *
        * Usage Example II:
        *
        * $data = array(
        *             'TITLE' => 'TemplateDemo - Userlist',
        *             'user'  => DB_read_all( 'select * from ris_user' )
        *         );
        * $page = new SmartTemplate( "template.html" );
        * $page->output( $data );
        *
        *
        * @author Philipp v. Criegern philipp@criegern.com
        * @author Manuel 'EndelWar' Dalla Lana endelwar@aregar.it
        * @version 1.2.1 03.07.2006
        *
        * CVS ID: $Id: class.smarttemplate.php,v 1.7 2006/07/02 22:17:15 endelwar Exp $
        */
        class SmartTemplate
        {
                /**
                * Whether to store compiled php code or not (for debug purpose)
                *
                * @access public
                */
                var $reuse_code                = true;

                /**
                * Directory where all templates are stored
                * Can be overwritten by global configuration array $_CONFIG['template_dir']
                *
                * @access public
                */
                var $template_dir        = 'templates/';

                /**
                * Where to store compiled templates
                * Can be overwritten by global configuration array $_CONFIG['smarttemplate_compiled']
                *
                * @access public
                */
                var $temp_dir                = 'templates_c/';

                /**
                * Temporary folder for output cache storage
                * Can be overwritten by global configuration array $_CONFIG['smarttemplate_cache']
                *
                * @access public
                */
                var $cache_dir      =  'templates_c/';

                /**
                * Default Output Cache Lifetime in Seconds
                * Can be overwritten by global configuration array $_CONFIG['cache_lifetime']
                *
                * @access public
                */
                var $cache_lifetime =  600;

                /**
                * Temporary file for output cache storage
                *
                * @access private
                */
                var $cache_filename;

论坛徽章:
0
24 [报告]
发表于 2006-08-01 09:23 |只看该作者
x



Warning: fopen(templates_c/hello_world_tpl_html.php) [function.fopen]: failed to open stream: No such file or directory in /var/www/temp/class.smarttemplateparser.php on line 255
SmartTemplate Parser Error: Could not write compiled file.

论坛徽章:
0
25 [报告]
发表于 2006-08-01 09:26 |只看该作者
现在的错误提示变成 :
  Warning: fopen(templates_c/hello_world_tpl_html.php) [function.fopen]: failed to open stream: No such file or directory in /var/www/temp/class.smarttemplateparser.php on line 255
SmartTemplate Parser Error: Could not write compiled file.

类源代码如下:
if ($hd = @fopen($template_filename, "r"))  //错误行
                        {
                                if (filesize($template_filename))
                                {
                                        $this->template = fread($hd, filesize($template_filename));
                                }
                                else
                                {
                                        $this->template = "SmartTemplate Parser Error: File size is zero byte: '$template_filename'";
                                }

论坛徽章:
0
26 [报告]
发表于 2006-08-01 09:40 |只看该作者
斑竹,还是不行,我的就报上面的错误啊~赶紧帮个忙啊

论坛徽章:
0
27 [报告]
发表于 2006-08-01 10:12 |只看该作者
原帖由 fendou_2005 于 2006-8-1 09:23 发表
x



Warning: fopen(templates_c/hello_world_tpl_html.php) [function.fopen]: failed to open stream: No such file or directory in /var/www/temp/class.smarttemplateparser.php on line 255
SmartTe ...


按你的路径配置一下
include "smarttemplate/class.smarttemplate.php";
//SmartTemplate配置
$_CONFIG = array(
        'smarttemplate_compiled'        =>        dirname(__FILE__) . '/cache/',
        'smarttemplate_cache'                =>        dirname(__FILE__) . '/cache/',
        'cache_lifetime'                        =>        3600,
        'template_dir'                                =>        dirname(__FILE__) . 'templates/',
        );

论坛徽章:
0
28 [报告]
发表于 2006-08-01 10:13 |只看该作者
原帖由 fendou_2005 于 2006-8-1 09:26 发表
现在的错误提示变成 :
  Warning: fopen(templates_c/hello_world_tpl_html.php) [function.fopen]: failed to open stream: No such file or directory in /var/www/temp/class.smarttemplateparser.php on lin ...


提示的很详细,在模版文件目录中找不到hello_world_tpl_html.php模版文件
templates_c/hello_world_tpl_html.php

你的模版文件放在什么地方

论坛徽章:
0
29 [报告]
发表于 2006-08-01 10:16 |只看该作者
bool $reuse_code

设置是否使用模板最后编译所产生的文件. 如果设置为 false, SmartTemplate 在每次使用到该模板时都会重新编译一次.

string $template_dir

设置模板文件的目录. 全局配置数组 $_CONFIG[’template_dir’] 也可以设置,并且覆盖此处的设置.

string $temp_dir

设置编译文件的目录. 全局配置数组 $_CONFIG[’smarttemplate_compiled’] 也可以设置,并且覆盖此处的设置. 当心: 请确认PHP有权限读写该目录,否则无法正常工作!

string $cache_dir

设置输出缓存的目录. 全局配置数组 $_CONFIG[’smarttemplate_cache’] 也可以设置,并且覆盖此处的设置. 当心: 请确认PHP有权限读写该目录,否则无法正常工作!

int $cache_lifetime

设置默认的输出缓存更新时间. 全局配置数组 $_CONFIG[’cache_lifetime’] 也可以设置,并且覆盖此处的设置.

论坛徽章:
0
30 [报告]
发表于 2006-08-01 10:19 |只看该作者
能说得具体点吗?我还不是很清楚,我的html和.php(代码)都放到1个文件夹下面了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP