Sunday, October 1, 2017

htmlspecialchars() expects parameter 1 to be string, array given Laravel 5.

This Error Happened in View where php trying to echo a value using the function htmlspecialchars(), and this function cannot accept an Array as its first Parameter.

Debug : if you are using Whoops for debugging your application you will see in the left panel a link to the view templates directory .

…\storage\framework\views\eec8a32e98fad0167a61a9f879d076bc29cad5a6.php 43
 
the number in red may change in your case , So open this file in any editor and find the line number 43 , you will find the echo function containing something  function as its parameter, like this :

echo e(app->Somthing()));

the e function is a laravel helper function , which apply htmlspecialchars() function to the expected string between brackets.


Now, the function inside the brackets is causing the error , Here it is the app->Something which is bringing an array as its result while htmlspecialchars () expecting a string , find this function in your view file and change it to give you a string not an array.

No comments:

Post a Comment