我有PHP函數叫做_to_unix_timestamp() 代碼:PHP的strtotime給出不同的結果在64位
function _to_unix_timestamp($param){
if ($timestamp = strtotime($param)){
return $timestamp;
}
return (int) $param;
}
的代碼是我的開發服務器上運行良好(32位)
但是當我部署我的應用生產服務器(64)從該函數輸出
是有點不同
例如
// expected to be "int(1306400175)" but the output is "int(-56632154432)"
var_dump(_to_unix_timestamp("1306400175"));
我的開發服務器上,輸出爲int(1306400175)
但生產服務器上,輸出爲INT(-56632154432)
只是信息 開發服務器(32位)=
的Linux 2.6.18 glustervm -164.el5xen#1 SMP星期四09月03日4時47分32秒EDT 2009的i686的i686 i386的GNU/Linux的
PHP 5.2.9
生產服務器(64位)=
Linux的minicapella 2.6.18-164.15.1 .el5.centos.plusxen#1 SMP Wed Mar 17 20:32:20 EDT 2010 x86_64 x86_64 x86_64 GN U/Linux的
PHP 5.2.13
現在的功能正在運行我追加
//append "> 0"
if ($timestamp = strtotime($param) > 0){
但是,我想知道爲什麼輸出是不同的後呢?
謝謝你的建議
-rizkyabdilah
strtotime確實在不同的平臺上不確定有關32位或64位的事情......但是它不同。.. strtotime('0000-00-00')在本地機器上給出「false」,同時在服務器上返回一個負整數。 – codisfy 2013-02-05 11:08:53