Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如果文件_存在,则Smarty_Php_Smarty - Fatal编程技术网

Php 如果文件_存在,则Smarty

Php 如果文件_存在,则Smarty,php,smarty,Php,Smarty,我是新的编码,有人能告诉我我做错了什么吗 我想查看文件夹中是否存在图像,但如果存在则不会显示该图像 {assign var="backimg" value="/thumbs/backgrounds/movie_bg/`$mov.title|lower|replace:' ':'_'`.jpg"} { if file_exists($backimg) } <div class="container_inner" style="background:url(/thumbs/background

我是新的编码,有人能告诉我我做错了什么吗

我想查看文件夹中是否存在图像,但如果存在则不会显示该图像

{assign var="backimg" value="/thumbs/backgrounds/movie_bg/`$mov.title|lower|replace:' ':'_'`.jpg"}
{ if file_exists($backimg) }
<div class="container_inner"
style="background:url(/thumbs/backgrounds/movie_bg/{$mov.title|lower|replace:' ':'_'}.jpg)no-repeat center;">
{else}
<div class="container_inner">
{/if}
{assign var=“backimg”value=“/thumbs/backgrounds/movie_bg/`$mov.title | lower |替换:'''.'.jpg'}
{如果文件_存在($backimg)}
{else}
{/if}

有人能告诉我我的代码是否有问题。

Smarty是一种模板语言。您不会将PHP代码写入这样的模板中。在调用模板的PHP代码中执行逻辑,将正确呈现页面所需的任何值分配给模板,然后呈现模板

// In the PHP code.
// (Simplified. The actual code to initialize Smarty will usually be more complex.)
$smarty = new Smarty();
$smarty->assign("file_exists", file_exists('/file/path'));
$smarty->display('mytemplate.tpl');

// In the 'mytemplate.tpl' template file.
{if $file_exists}
    <p>File exist!</p>
{else}
    <p>File doesn't exist</p>
{/if}
//在PHP代码中。
//(简化。初始化Smarty的实际代码通常更复杂。)
$smarty=新smarty();
$smarty->assign(“文件存在”,文件存在('/file/path');
$smarty->display('mytemplate.tpl');
//在“mytemplate.tpl”模板文件中。
{如果$file_存在}
文件存在

{else} 文件不存在

{/if}
相关的html代码是否出现在源代码中?当从web访问时,它可以有不同于从文件系统访问时的路径