简体   繁体   English

如何用php函数回显href?

[英]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 ';' 它出错:解析错误:语法错误,意外T_STRING,期待','或';'

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. echo是一个函数,用于打印其参数。 You can actually call echo like this: echo("hello"); 你可以像这样调用echoecho("hello"); , which is syntactically identical to echo "hello"; ,在语法上与echo "hello";相同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. 如果你正在调用echo ,你已经处于php模式(即:在你的echo调用之前有一个开放的<?php ),所以不需要为get_bloginfo调用再次进入php模式。 get_bloginfo returns a string, so you can just concatenate its output with the rest of your echo parameter. get_bloginfo返回一个字符串,因此您可以将其输出与echo参数的其余部分连接起来。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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