Smarty-Urlencode中的PHP代码


PHP Code in Smarty - Urlencode

我有一部分代码混合了PHP和Smarty。如何在Smarty中编写所有代码?

{php}$shortenedurl = file_get_contents('http://url.to/api.php?url=' . urlencode({$ShopURL}/index.php?wlid={$CWunschliste->cURLID});{/php}
<input type="text" id="wunschliste_public_url" value="{php}echo $shortenedurl;{/php}" />

您不应该以这种方式使用Smarty。您应该在PHP中执行这样的操作,并分配Smarty变量。Smarty是模板引擎,您应该只使用它来显示数据。如果您以这种方式使用模板引擎(Smarty或任何其他),则根本没有必要使用它。这只会影响你的表现,不会给你带来任何好处。