Heim >Backend-Entwicklung >PHP-Tutorial >关于smarty的is_cached()方法的问题请大神帮忙.万分感激.

关于smarty的is_cached()方法的问题请大神帮忙.万分感激.

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-20 12:30:471086Durchsuche

Fatal error:  Uncaught  --> Smarty: Smarty->is_cached() undefined method 

今天用了if(!is_cached("var.html",$_SERVER["REQUEST_URI"])){
echo "today is beautiful day!
";
}
来测试smarty是否缓存,出现以上的错误,我的smarty的版本是:smarty-3.1.29.是不是我用的smarty版本没有了这个方法?如果不用这个方法,那又是用什么方法来代替?请大神帮忙解决.万分感激....


回复讨论(解决方案)

那您 print_r(get_class_methods('Smarty')); 看一下不就知道啦?

再说,你写成 if(!is_cached("var.html",$_SERVER["REQUEST_URI"])){ 也是不对的吧?

二楼,用
echo '

';  <br>var_dump($smarty);  <br>echo'<pre class="brush:php;toolbar:false">';  <br>得的结果是以下,  <br>object(Smarty)#1 (65) {  <br>  ["auto_literal"]=>  <br>  bool(true)  <br>  ["error_unassigned"]=>  <br>  bool(false)  <br>  ["use_include_path"]=>  <br>  bool(false)  <br>  ["template_dir":"Smarty":private]=>  <br>  array(1) {  <br>    [0]=>  <br>    string(42) "/usr/local/apache2/htdocs/www/smarty/temp/"  <br>  }  <br>  ["_joined_template_dir"]=>  <br>  string(42) "/usr/local/apache2/htdocs/www/smarty/temp/"  <br>  ["_joined_config_dir"]=>  <br>  string(44) "/usr/local/apache2/htdocs/www/smarty/configs"  <br>  ["default_template_handler_func"]=>  <br>  NULL  <br>  ["default_config_handler_func"]=>  <br>  NULL  <br>  ["default_plugin_handler_func"]=>  <br>  NULL  <br>  ["compile_dir":"Smarty":private]=>  <br>  string(41) "/usr/local/apache2/htdocs/www/smarty/com/"  <br>  ["plugins_dir":"Smarty":private]=>  <br>  NULL  <br>  ["cache_dir":"Smarty":private]=>  <br>  string(43) "/usr/local/apache2/htdocs/www/smarty/cache/"  <br>  ["config_dir":"Smarty":private]=>  <br>  array(1) {  <br>    [0]=>  <br>    string(44) "/usr/local/apache2/htdocs/www/smarty/configs"  <br>  }  <br>  ["force_compile"]=>  <br>  bool(false)  <br>  ["compile_check"]=>  <br>  bool(true)  <br>  ["use_sub_dirs"]=>  <br>  bool(false)  <br>  ["allow_ambiguous_resources"]=>  <br>  bool(false)  <br>  ["merge_compiled_includes"]=>  <br>  bool(false)  <br>  ["force_cache"]=>  <br>  bool(false)  <br>  ["left_delimiter"]=>  <br>  string(2) "  ["right_delimiter"]=>  <br>  string(2) "}>"  <br>  ["security_class"]=>  <br>  string(15) "Smarty_Security"  <br>  ["security_policy"]=>  <br>  NULL  <br>  ["php_handling"]=>  <br>  int(0)  <br>  ["allow_php_templates"]=>  <br>  bool(false)  <br>  ["debugging"]=>  <br>  bool(false)  <br>  ["debugging_ctrl"]=>  <br>  string(4) "NONE"  <br>  ["smarty_debug_id"]=>  <br>  string(12) "SMARTY_DEBUG"  <br>  ["debug_tpl"]=>  <br>  NULL  <br>  ["error_reporting"]=>  <br>  NULL  <br>  ["config_overwrite"]=>  <br>  bool(true)  <br>  ["config_booleanize"]=>  <br>  bool(true)  <br>  ["config_read_hidden"]=>  <br>  bool(false)  <br>  ["compile_locking"]=>  <br>  bool(true)  <br>  ["cache_locking"]=>  <br>  bool(false)  <br>  ["locking_timeout"]=>  <br>  int(10)  <br>  ["default_resource_type"]=>  <br>  string(4) "file"  <br>  ["caching_type"]=>  <br>  string(4) "file"  <br>  ["default_config_type"]=>  <br>  string(4) "file"  <br>  ["resource_cache_mode"]=>  <br>  int(1)  <br>  ["cache_modified_check"]=>  <br>  bool(false)  <br>  ["registered_plugins"]=>  <br>  array(0) {  <br>  }  <br>  ["registered_objects"]=>  <br>  array(0) {  <br>  }  <br>  ["registered_classes"]=>  <br>  array(0) {  <br>  }  <br>  ["registered_filters"]=>  <br>  array(0) {  <br>  }  <br>  ["registered_resources"]=>  <br>  array(0) {  <br>  }  <br>  ["registered_cache_resources"]=>  <br>  array(0) {  <br>  }  <br>  ["autoload_filters"]=>  <br>  array(0) {  <br>  }  <br>  ["default_modifiers"]=>  <br>  array(0) {  <br>  }  <br>  ["escape_html"]=>  <br>  bool(false)  <br>  ["start_time"]=>  <br>  float(1461252359.6399)  <br>  ["_current_file"]=>  <br>  NULL  <br>  ["_parserdebug"]=>  <br>  bool(false)  <br>  ["_objType"]=>  <br>  int(1)  <br>  ["_debug"]=>  <br>  NULL  <br>  ["cache_id"]=>  <br>  NULL  <br>  ["compile_id"]=>  <br>  NULL  <br>  ["caching"]=>  <br>  int(1)  <br>  ["cache_lifetime"]=>  <br>  int(3600)  <br>  ["_cache"]=>  <br>  array(6) {  <br>    ["template_dir_new"]=>  <br>    bool(true)  <br>    ["template_dir"]=>  <br>    bool(false)  <br>    ["compile_dir"]=>  <br>    bool(true)  <br>    ["config_dir_new"]=>  <br>    bool(true)  <br>    ["config_dir"]=>  <br>    bool(false)  <br>    ["cache_dir"]=>  <br>    bool(true)  <br>  }  <br>  ["template_class"]=>  <br>  string(24) "Smarty_Internal_Template"  <br>  ["tpl_vars"]=>  <br>  array(0) {  <br>  }  <br>  ["parent"]=>  <br>  NULL  <br>  ["config_vars"]=>  <br>  array(0) {  <br>  }  <br>  ["ext"]=>  <br>  object(Smarty_Internal_Extension_Handler)#2 (3) {  <br>    ["objType"]=>  <br>    int(1)  <br>    ["_property_info":"Smarty_Internal_Extension_Handler":private]=>  <br>    array(7) {  <br>      ["AutoloadFilters"]=>  <br>      int(0)  <br>      ["DefaultModifiers"]=>  <br>      int(0)  <br>      ["ConfigVars"]=>  <br>      int(0)  <br>      ["DebugTemplate"]=>  <br>      int(0)  <br>      ["RegisteredObject"]=>  <br>      int(0)  <br>      ["StreamVariable"]=>  <br>      int(0)  <br>      ["TemplateVars"]=>  <br>      int(0)  <br>    }  <br>    ["resolvedProperties":"Smarty_Internal_Extension_Handler":private]=>  <br>    array(0) {  <br>    }  <br>  }  <br>}  <br>没有is_cached()此方法,我问题要问的是,如果没有is_cached()这个方法,哪用什么方法来代替?不胜感谢...  <br>  <p class="sougouAnswer">  谢谢二楼,已经搞掂。。。。 </p>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn