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

末鹿安然 提交于 2019-12-01 14:46:30

This is not a Laravel specific error:

in php documents if you see

htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);

this function accepts, 2 parameters, first one is a string and second is an optional parameter.

If you have an array of strings to be escaped then use foreach and escape each string

There is an array anywhere in one of your Blade {{}}, please check them.

Read: https://laravel.com/docs/5.6/blade#displaying-data

You are using Array inside {{}} somewhere. You can only use String inside {{}}.

use {{dd(variable_name)}} to check the variable before you use it inside {{}}. if its an array convert it into String first ( using implode()) ).

implode documentation: http://php.net/manual/en/function.implode.php

blade documentation: https://laravel.com/docs/5.6/blade#displaying-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!