【问题标题】:Exception Message -> Array to string conversion" Laravel异常消息 -> 数组到字符串的转换” Laravel
【发布时间】:2021-06-23 15:48:03
【问题描述】:

我正在使用 Laravel Lucid 框架,我必须显式调用模型 setAttribute,但出现以下错误:

ErrorException: 数组到字符串的转换

代码是

$user = new User;
$user->setAttribute('email',$this->email);
print_r($user);exit();

请帮忙

谢谢

【问题讨论】:

  • dd($this->email) 输出什么?
  • 它是简单的电子邮件地址,类似 (test@test.com) 的字符串
  • 以下哪一行会引发该错误?您尝试过什么来解决问题?

标签: php laravel lucid


【解决方案1】:

尝试使用 implode() 方法? :

$test = implode('', $array);

$user = new User;
$user->setAttribute('email', $test);
print_r($user);
exit();

【讨论】:

    猜你喜欢
    • 2016-10-18
    • 2020-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-22
    • 2016-07-08
    • 1970-01-01
    相关资源
    最近更新 更多