简体   繁体   中英

get variable smarty in php tag

We want to make date whmcs7 Gregorian dates change from the jalali That's why we put the following code in the file tpl smarty

{$invoice.datecreated}
{php}
    include_once ($_SERVER["DOCUMENT_ROOT"] ."/templates/six/jdf.php");
    $date = '{$invoice.datecreated}';
    list($g_y, $g_m, $g_d) = explode("/", $date);
    $str="/";
    print "(".gregorian_to_jalali ($g_y, $g_m, $g_d,$str).")";
{/php}

But this piece of code instead of putting on the variable The insertion string

$date = '{$invoice.datecreated}';
print $date;  // result: invoice.datecreated Instead 2015/01/31

please guide me

I think you need double quotes.

$date = "{$invoice.datecreated}"; //double quotes here as "
print $date;

Example:

$name = "My name";

echo '{$name}';//outputs {$name}
echo "{$name}";//outputs My name

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