你好,我正在使用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
函数,以便检查文件是否存在?