0
我正確地檢索我的數據表單解析,但是當試圖調用函數getCreatedAt時它不起作用。解析PHP getCreateAt
我正確地獲取其他信息是這樣的:
$obj->get(' description');
但調用getCreatedAt當頁面無法正常工作,並拋出這個錯誤:
__toString() must not throw an exception
我試圖得到這樣的時間戳
$obj->get('createdAt');
$obj->getCreatedAt();
但是沒有工作。
有誰知道可能會發生什麼?
http://www.andrew-kirkpatrick.com/2013/04/how-to-safely-handle-php-__tostring-must-not-throw-an-exception/ – 2014-09-19 17:22:48
我已經讀過,但問題沒有處理異常,但檢索日期,它說它是NULL。無論如何感謝 – manuvendev 2014-09-19 17:26:16
createdAt變量是一個DateTime對象,所以問題可能與初始化。它可能被提供了一個不正確的值,導致它在調用它的內部toString方法時出錯。我會建議編輯getCreatedAt函數並在try catch中包裝返回以獲取異常。 – cdr 2014-09-19 17:32:53