我知道我們應該避免任何模板引擎內的{php}標籤,但是,讓我們假設它是這種情況下唯一的方法。如何抓住smarty的字符串爲php消費
考慮到這一點,我想請求一些幫助,以抓住聰明的字符串爲PHP消費。
在這種情況下,我想訪問srtstr php函數中的$ video.yt_id。
我在做什麼錯?
如何抓取聰明的字符串{$ video.yt_id}的PHP消費?
{php}
$youtube = new YouTube('I-WANT-THE-YOUTUBE-ID-HERE');
$meta = $youtube->get_meta();
$author = $youtube->get_author();
$comments = $youtube->get_comments();
{/php}
<p>
Duration: {php} echo sprintf("%0.2f", $meta['duration']/60); {/php}mins |
Rated: {php} echo $meta['rating']; {/php} out of 5 |
Posted by {php} echo $author['username']; {/php} ({php} echo $author['age']; {/php} y/o from {php} echo $author['location']; {/php})
{php} echo nl2br($meta['description']); {/php}
</p>
不,不要假設。順便說一下,這是充滿'{php}'標籤,我不相信你使用smarty。 – Alexander