課程
/后端開發
/PHP
/輕松學會Laravel-表單篇
update報錯"Call to a member function format() on string" 有人能夠解決一下這個問題嗎 謝謝
2018-01-30
源自:輕松學會Laravel-表單篇 2-7
正在回答
public?function?fromDateTime($value) { ????return?empty($value)???$value?:?$this->getDateFormat(); }
在student模型添加這段代碼就可以了
同樣錯誤
Symfony \ Component \ Debug \ Exception \FatalThrowableError?(E_ERROR)
Call to a member function format() on string
我在做 update 的時候也報了同樣的錯。錯誤定位在:?
public function fromDateTime($value)
? ?{
? ? ? ?return empty($value) ? $value : $this->asDateTime($value)->format(
? ? ? ? ? ?$this->getDateFormat()
? ? ? ?);
? ?}
?很奇怪的是,新建一條記錄不會出錯,但是在更新記錄的時候就會報錯。
沒有看代碼不知道錯誤在哪里,看報錯你是對一個字符串變量調用成員方法了么?只有對象能調用方法。
舉報
Laravel框架是世界上最流行的PHP框架,沒有之一
2 回答Call to a member function format() on string 或者 Call to a member function format() on integer
1 回答call to member function sex() on string
2 回答?Call to a member function format() on string 有沒有出現這樣錯誤的呀?
2 回答to a string?
1 回答Call to undefined function Illuminate\Encryption\openssl_encrypt()
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2018-07-26
在student模型添加這段代碼就可以了
2018-05-23
同樣錯誤
Symfony \ Component \ Debug \ Exception \FatalThrowableError?(E_ERROR)
Call to a member function format() on string
2018-03-16
我在做 update 的時候也報了同樣的錯。錯誤定位在:?
public function fromDateTime($value)
? ?{
? ? ? ?return empty($value) ? $value : $this->asDateTime($value)->format(
? ? ? ? ? ?$this->getDateFormat()
? ? ? ?);
? ?}
?很奇怪的是,新建一條記錄不會出錯,但是在更新記錄的時候就會報錯。
2018-02-07
沒有看代碼不知道錯誤在哪里,看報錯你是對一個字符串變量調用成員方法了么?只有對象能調用方法。