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

后端 未结 3 875
眼角桃花
眼角桃花 2021-01-17 01:35

Already done a research but I don\'t find the right answer that fit my problem.

error: htmlspecialchars() expects parameter 1 to be string, array given(create.blade)

相关标签:
3条回答
  • 2021-01-17 01:47

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

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

    0 讨论(0)
  • 2021-01-17 01:59

    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

    0 讨论(0)
  • 2021-01-17 02:03

    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

    0 讨论(0)
提交回复
热议问题