php - Why does this echo values in the wrong order?

I'm sure there is a simple reasonanswer for this: Why does echo 'Archive for '. the_time('Y');

I'm sure there is a simple reason/answer for this: Why does

echo 'Archive for '. the_time('Y');

give me 2010Archive for? I had expected it would give me Archive for 2010

I'm sure there is a simple reason/answer for this: Why does

echo 'Archive for '. the_time('Y');

give me 2010Archive for? I had expected it would give me Archive for 2010

Share Improve this question edited Dec 6, 2010 at 13:52 gillespieza asked Dec 6, 2010 at 13:47 gillespiezagillespieza 1,2855 gold badges26 silver badges46 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 8

As most template tags that start with the_ this one echoes time and not returns it (which template tags that start with get_the_ do).

First the_time() fires and echoes year, then its return (null) gets concatenated and echoed with string.

So:

echo 'Archive for ';
the_time('Y');

Or:

echo 'Archive for ' . get_the_time('Y');

You can also use ',' instead of '.' for concatenating strings in echo funcion.

echo 'Archive for ' , the_time('Y');

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742387570a4434364.html

相关推荐

  • php - Why does this echo values in the wrong order?

    I'm sure there is a simple reasonanswer for this: Why does echo 'Archive for '. the_time('Y');

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信