如何在PHP中调用Smarty

时间:2014-12-29 13:25:44

标签: php smarty

如何在{$Artikel->cArtNr}内拨打Smarty {php} {/php}? 反正有吗?

我正在运行一个Smarty引擎系统,所有系统都是用Smarty构建的。

{php}   

// Inputs
$shorturl = 'http://' . $_SERVER['HTTP_HOST']  . $_SERVER['REQUEST_URI'];
$signature = "1234567";
$siteurl = "http://test.it";
$articlenumber = $Artikel->cArtNr;

// Phases url
$yourlsinput = "".$siteurl."/yourls-api.php?action=shorturl&url=".$shorturl."&signature=".$signature."" ;

// Open phased url
$fh = fopen($yourlsinput, 'r') or die("can't open file");
//$yourlsoutput = fread($fh,filesize($yourlsinput));
$yourlsoutput = fread($fh,1024);
fclose($fh);

// Converts xml to php array
$xml = simplexml_load_string($yourlsoutput);
$json = json_encode($xml);
$array = json_decode($json,TRUE);

// Output status
echo "<body><p><b>Status:</b> ".$array['status']."<br>";
echo "<b>Message:</b> ".$array['message']."<br>";
echo "<b>Short url:</b> <a href='".$array['shorturl']."'>".$array['shorturl'] . $Artikel->cArtNr."</a></p>";
{/php}

0 个答案:

没有答案