我试图将当前月份保存为一个变量,然后根据该值,我希望它显示月份的全名。当我在函数中使用 the_time() 时,它会自动将其输出,这是我不想要的。
代码如下:
$month = the_time('M');
if($month == 'Aug') { echo 'August'; }
如何将 the_time('M') 的值保存在变量中以在 if 语句中使用而不回显该值?
顺便说一句,我知道我可以使用 the_time() 函数来回显月份的全名,但我将其用作测试。基于 the_time() 是什么,我想显示与月份对应的不同图像。
最佳答案
How can I save the value of the_time('M') in a variable to use in an if statement without it echoing out the value?
Wordpress 中的每个 the_...
函数都有一个 get_the_...
等效函数,它将返回值而不是回显它。
关于php - 为什么我不能在使用 WordPress 的 if 语句中使用 the_time() 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7266783/