简体   繁体   中英

How to echo href with php function inside?

How to echo this:

echo '<link rel="stylesheet" type="text/css" href="<?php echo get_bloginfo('template_url');?>/tryme.css">';

Am I doing right? It gets an error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'

Please help. THank you.

echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('template_url') . '/tryme.css">';

echo is a function, which prints its argument. You can actually call echo like this: echo("hello"); , which is syntactically identical to echo "hello";

if you are calling echo , you are already in php mode (ie: there's an open <?php somewhere before your echo call), so there's no need to enter php mode again for the get_bloginfo call. get_bloginfo returns a string, so you can just concatenate its output with the rest of your echo parameter.

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