PHP:根据季节设置图像? [英] PHP: setting image based on season?

查看:110
本文介绍了PHP:根据季节设置图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想在我的网站上设置一个头像(一个是冬季,一个是夏天)基于它是一个冬天或一个summermont。



所以我想知道最简单的方法是什么?我使用日期('n'),并查询返回值是否为冬季或总结。



你会做什么?



感谢你的提示。

解决方案

是的,你应该使用 date('n')。例如:

  function get_image()
{
$ summer = array(4,5 ,6,7,8,9);
return in_array(date('n'),$ summer)? 'summer.png':'winter.png'
}


hey guys, what's you take on this.

i want to set a header image on my website (one for winter and one for summer) based on wheter it is a wintermonth or a summermont.

so i wonder what would be the easiest way to that? i thougth of using date('n') and query wheter the returned value is true for a winter or summermonth.

what would you do?

thank you for your tips.

解决方案

Yeah you should use date('n'). For example like this:

function get_image()
{
    $summer = array(4,5,6,7,8,9);
    return in_array(date('n'), $summer) ? 'summer.png' : 'winter.png';
}

这篇关于PHP:根据季节设置图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆