Home  >  Article  >  Backend Development  >  php自动更新版权信息显示的方法_php技巧

php自动更新版权信息显示的方法_php技巧

WBOY
WBOYOriginal
2016-05-16 20:13:06852browse

本文实例讲述了php自动更新版权信息显示的方法。分享给大家供大家参考。具体分析如下:

我们一般会在页面下方输出版权信息,包含年份信息,每年都要修改,这段简单的代码帮你解决这个问题,自动更新年份

function autoUpdatingCopyright($startYear){
  // given start year (e.g. 2004)
  $startYear = intval($startYear);
  // current year (e.g. 2007)
  $year = intval(date('Y'));
  // is the current year greater than the
  // given start year?
  if ($year > $startYear)
    return $startYear .'-'. $year;
  else
    return $startYear;
}
//用法:
print '© ' . autoUpdatingCopyright(2001) . ' jb51.net';
/*
Output:
(c) 2001-2012 jb51.net
*/

希望本文所述对大家的php程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn