【发布时间】:2015-10-05 06:41:33
【问题描述】:
您好,我使用的是 slim 框架和 twig,这是我当前在 php 中的代码:
$filename = '/path/to/foo.txt';
if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
现在我想将 if 语句放在我的模板文件中。如何在我的 twig 模板中使用 file_exists 函数来检查文件是否存在?
【问题讨论】:
-
我认为可以在这里找到更好的解决方案stackoverflow.com/a/38737766/1077915
标签: php twig file-exists