在本例中,为什么在 html 文件中的 php 中需要回显?

Why echo is necessary in php inside html files, in this example?

我想知道:

为什么我这个代码有效:

<a href="<?php the_permalink(); ?>">go to this post</a>

但要检索以下值,我必须使用 echo,否则它将不起作用:

<a href="<?php echo get_option('home'); ?>">back to homepage</a>

我看了一眼get_option documentation,上面写着:

Return# - (mixed) Value set for the option.

所以也许这是不同的,这个函数的 return 值不是字符串?

the_permalink() 在函数调用中调用 echo。参见full source hereget_option() 只有 returns 一个值,所以如果你想要它在 html.

中,你必须显式地回显它

我不确定,但是如果您查看 the_permalink(); 方法的主体,您可能会在方法末尾看到 echo 命令,而 get_option('home'); 只是 return一个字符串作为结果。