简体   繁体   中英

smarty fetch php file not working

I want to fetch a php file in my .tpl but it will be display as plain text. if i use include it works, but need to fetch it.

  {fetch file="http://domain.xy/index.php?c=2"}

thx for help

{php}
  //include php code to get the text file here
{/php}

You could maybe do something like this and include the php code you need between the tags. The php tags let you put straight php into the template.

Or it may be better to fetch the file content before you load the template and assign it to a smarty variable then call the template. Something like this:

$smarty->assign('some_var', file_get_contents ('http://domain.xy/index.php?c=2'));
$smarty->display('the_current.tpl');

thx. the following code works for me

{php}
$url = file_get_contents('http://domain.xy/index.php?c=1');
echo $url;
{/php}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM