The Call of this PHP Code below in Smarty will not work
Sample Usage in PHP
$content=@file_get_contents("http://www.gempixel.com/short/api/?url=http://www.google.com&api=APIKEY");
$url=json_decode($content,TRUE);//Decodes json into an array
if(!$url["error"]){ // If there is no error
echo $url["short"]; //Outputs the short url
}else{
echo $url["msg"]; //Outputs the error message
}
For Smarty I just need to replace php with {php} and it should work.
{php}$shortenedurl = file_get_contents('http://www.gempixel.com/short/api/?api=fAaFjILdbigF&url=' . urlencode('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']));{/php}
{php}$url=json_decode($content,TRUE);if(!$url["error"]){echo $url["short"];}else{echo $url["msg"];}{/php}
But it will not call the string. What am I doing wrong?
first you need to assign varible value to smarty
$iframe="hiii";
$smarty->assign( 'iframe', $iframe ); //$smarty is a global var to assign
then get it your .tpl file
{$iframe}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.