This topic created in 4462 days ago, the information mentioned may be changed or developed.
<?php the_content() ?> 与 <?=the_content() ?>
这样写等效么?两者有什么区别?
我目前测试的结果是等效的。
另外,我想在这里面添加图片,但是路径不会写,求教。
我测试的结果
<?= the_content("<img src='/images/pc_bt.png' width='120' height='20' />") ?>
这么写不对,求指导
3 replies • 1970-01-01 08:00:00 +08:00
 |
|
1
Andor_Chen Mar 19, 2014
1. 不要用简写的 tag,用 <?php ?>; 2. 图片的路径取决于你的图片放在哪儿,一般如果放在主题文件夹中可以这么写:<?php echo get_template_directory_uri() . 'images/pc_bt.png'; ?>
多看 WordPress Codex
|
 |
|
2
qiayue Mar 19, 2014 1
<?=$foo?> 相当于 <?php echo $foo;?> <?php the_content(); ?> 是调用 the_content() 函数,<?=the_content()?> 是调用 the_content() 函数,并且打印函数返回值。
|
 |
|
3
jianghu52 Mar 20, 2014
@ qiayue 非常感谢,你这么说我就明白了。因为 the_content() 函数本身就在函数内有echo输出的内容,所以在wordpress上是等效的。
|