lundi 25 juin 2018

htmlspecialchars() expects parameter 1 to be string, array given (View: C:\xampp\htdocs\blog\resources\views\welcome.blade.php)

I just started learning laravel and for some reason I cant get this array to print. I am getting this error htmlspecialchars() expects parameter 1 to be string, array given (View: C:\xampp\htdocs\blog\resources\views\welcome.blade.php). some help me how do i get this fixed??

//this is the web.php

Route::get('/', function () {
$names =[ 
    'Demo',
    'Demo 1',
    'Demo 2'
];    
return view('welcome', compact('names'));
});

//welcome.blade.php

<!doctype html>
<html >
    <head>
        <title>Laravel</title>
    </head>
    <body>
            <ul>        
            @foreach($names as $name) 
                <li> </li>
            @endforeach
    </ul>
    </body>
</html>




Aucun commentaire:

Enregistrer un commentaire