Php htmlspecialchars()要求参数1为字符串,数组给定(将用户名传递到破折号)
我知道这是一个重复的问题,但我没有得到答案,所以我创造了新的 这是我的控制器 这是我的blade.php页面和代码Php htmlspecialchars()要求参数1为字符串,数组给定(将用户名传递到破折号),php,laravel,Php,Laravel,我知道这是一个重复的问题,但我没有得到答案,所以我创造了新的 这是我的控制器 这是我的blade.php页面和代码 @if (session('status')) <div class="alert alert-success"> {{ session('status') }} </div> @endif 我犯的错误 htmlspecialchars期望参数1是字符串,数组给定视图:C:\xampp\htdocs\resources\vi
@if (session('status'))
<div class="alert alert-success">
{{ session('status') }}
</div>
@endif
我犯的错误
htmlspecialchars期望参数1是字符串,数组给定视图:C:\xampp\htdocs\resources\views\dashboard.blade.php
如果您想在blade.php上只显示状态消息,那么您只需要从控制器传递状态消息
return redirect('dashboard')->with('status', "Your status message here.");
return redirect('dashboard')->with('status', $checklogin["status"]);
如果要在$checklogin中显示收到的完整结果
return redirect('dashboard')->with('status', $checklogin); //In Controller
@if (session('status'))
<div class="alert alert-success">
<?php
echo "<pre>";
print_r($status);
?>
</div>
@endif
{{}}被解析并通过htmlentities。这基本上是一笔不多的钱。长话短说,会话“status”是一个数组,它被传递到htmlentities中。{{}在Blade中默认清理字符串,$checklogin不是字符串而是数组。里面有什么?执行dd$checklogin;,您可能只想打印一个特定的键,->带有'status',$checklogin[status];那么我应该放什么呢。@Andrew在会话'status'上打印输出迭代是正确的,因为它不是一个字符串,而是一个数组。或者,您可以使用内爆“,”会话“status”将其连接为stringi,我想将checklogin的值传递到我的blade中。它如何工作??我尝试了你的答案,但上面写着“未定义状态”,请先尝试这个。返回重定向“dashboard”->和“status”,您的状态信息在此显示。;是的,如果值是字符串{{status}},它就工作了。如果我将字符串您的状态消息更改为$checklogin,它就不工作了怎么办
return redirect('dashboard')->with('status', $checklogin); //In Controller
@if (session('status'))
<div class="alert alert-success">
<?php
echo "<pre>";
print_r($status);
?>
</div>
@endif