This content originally appeared on CodeSource.io and was authored by Deven
If you are getting htmlspecialchars() expects parameter 1 to be string, array given error, this article will help you fix the issue.
Consider the example below:
@foreach($data->ac['0'] as $link)
<a href="{{ $link['url'] }}">This is a link</a>
@endforeach
When you use a blade echo {{ $data }}
it will automatically escape the output. It can only escape strings. In the snippet above data $data->ac
is an array and $data
is an object, neither of which can be echoed as is. You need to be more specific of how the data should be outputted.
If you if you intend to send the full array from the HTML to the controller, can use this:
<input type="hidden" name="quotation" value="{{ json_encode($quotation,TRUE)}}">
and update your controller like below:
public function Get(Request $req) {
$quotation = array('quotation' => json_decode($req->quotation));
}
The post Fix – htmlspecialchars() expects parameter 1 to be string, array given appeared first on CodeSource.io.
This content originally appeared on CodeSource.io and was authored by Deven
Deven | Sciencx (2021-02-26T15:43:09+00:00) Fix – htmlspecialchars() expects parameter 1 to be string, array given. Retrieved from https://www.scien.cx/2021/02/26/fix-htmlspecialchars-expects-parameter-1-to-be-string-array-given/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.