经测试代码如下:
/**
* 输出版权信息
*
* @param
* @arrange (512.笔记) jb51.cc
**/
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.cc';
/*
Output:
(c) 2001-2012 jb51.cc
*/
/*** 代码来自编程之家 jb51.cc(jb51.cc) ***/