0
是應01,但我發現1而不是PHP的日期( 'M')是顯示單個數字月份,根據php.net日期( 'M')不是雙
dirloc = date('Y') . "/" . date('m') . "/" . $word_id . "/";
是應01,但我發現1而不是PHP的日期( 'M')是顯示單個數字月份,根據php.net日期( 'M')不是雙
dirloc = date('Y') . "/" . date('m') . "/" . $word_id . "/";
Install PHPUnit.Run the following UnitTest:
// make sure PHPUnit is included
class DateTest extends PHPUnit_Framework_TestCase
{
public function setup()
{
date_default_timezone_set('UTC');
}
public function getDates()
{
return array(
array('01', 'Jan'),
array('02', 'Feb'),
array('03', 'Mar'),
array('04', 'Apr'),
array('05', 'May'),
array('06', 'Jun'),
array('07', 'Jul'),
array('08', 'Aug'),
array('09', 'Sep')
);
}
/**
* @dataProvider getDates
*/
public function testDateReturnsMonthWithLeadingZero($expected, $month)
{
$this->assertSame($expected, date('m', strtotime($month)));
}
}
如果測試失敗並出現任何給定的測試日期,請收集您的PHP版本和操作系統,並向PHP錯誤跟蹤器報告錯誤。如果測試通過了所有測試日期,那麼您正在做其他事情。
什麼是PHP版本? – deceze 2010-12-13 10:05:08
@deceze ver 5.2.14 – acctman 2010-12-13 10:09:36
該代碼片段可以在我的機器上正常工作。 – 2010-12-13 10:10:50