我在smarty模板中导入了一个广告文件,但是我不知道这个广告文件是否存在,如果文件不存在的话会报错,怎样才能不报错啊,(注:我不想用assign传参,因为广告文件特别多,所以我不可能在php文件中一个一个去判断是否存在)smarty模板中部分代码如下:
<div><{include file="../../include/menu_tags_up_button.inc"}></div>报错:
Warning: Smarty error: unable to read resource: "../../include/menu_tags_up_button.inc" in.....
如上述所述,如果"../../include/menu_tags_up_button.inc"文件不存在就会报错,当然,存在就什么问题都没有了,求高手解答啊
<div><{include file="../../include/menu_tags_up_button.inc"}></div>报错:
Warning: Smarty error: unable to read resource: "../../include/menu_tags_up_button.inc" in.....
如上述所述,如果"../../include/menu_tags_up_button.inc"文件不存在就会报错,当然,存在就什么问题都没有了,求高手解答啊
如果想不报错,就设置php的display_error...之类的配置就好了呀。
嵌套php脚本{php}if(file_exists(path)){ include(path); }{/php}
在文档加载的时候判断../include/menu_tags_up_button.inc"是否存在
如果存在则……
否则……
可以使用jQuery的$.ajax()方法判断能否响应请求,如果失败则不存在,否则存在