Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何检查 Smarty 2 中是否存在文件?我的意思是这样的:
{assign var="module_js" value="/js/modules/{$module}.js"} {if file_exists($module_js)} <script type="text/javascript" src="{$module_js}"></script> {/if}
实际上,这与 Smarty 版本无关。但是你分配变量的方式是错误的。试试这个方法:
{assign var="module_js" value="js/`$module`.js"} {if file_exists($module_js)} <script type="text/javascript" src="{$module_js}"></script> {/if}