如何在内部使用php函数回显href


How to echo href with php function inside?

如何回应这个:

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

我做得对吗?它得到一个错误:分析错误:语法错误,意外的T_STRING,应为","或";"

请帮忙。非常感谢。

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

echo是一个函数,它打印它的参数。实际上,您可以这样调用echoecho("hello");,它在语法上与echo "hello"; 相同

如果您正在调用echo,那么您已经处于php模式(即:在echo调用之前的某个位置有一个打开的<?php),因此无需再次为get_bloginfo调用进入php模式。get_bloginfo返回一个字符串,因此您可以将其输出与echo参数的其余部分连接起来。