简体   繁体   中英

How I can call $x variable of Php inside shortcode of a plugin Wordpress?

$dt = date_default_timezone_set('America/New_York');
$dt = date("h:i:s");
$x = date('d-m-Y');
$d = $dt;
//echo $x." ".$d;
echo do_shortcode('[tminus t= "10-10-2015 00:00:00"]');
//echo do_shortcode('[tminus t= "'.$x.'""00:00:00"]');

I have used $x variable inside shortcode but my site goes blank, due to syntax error I know it. But how can I call variable in this shortcode please any one can tell me?

you could use string substitution with "..$x.." or concatenate the strings

Concatenation:

echo do_shortcode('[tminus t= "' . $x . ' 00:00:00"]');

Substitution (vars will be expanded):

echo do_shortcode("[tminus t= \"$x 00:00:00\"]");

for more details, you should have a look at http://www.php.net/manual/en/language.types.string.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