mercredi 28 juin 2017

My variable does not seem to be available in blade view

My Route...

   Route::get('/test', function () {

    $word = ['Hello'];



    return view('test', $word);
});

My Blade View...

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Laravel Quickstart - Basic</title>
    <link href="" rel="stylesheet"/>
    <link href="" rel="stylesheet"/>
    <!-- CSS And JavaScript -->
</head>

<body>

<div class="container">
    <nav class="navbar navbar-default">
        
    </nav>
</div>



</body>
</html>

I get the following erro when accessing the app via a browser...

(2/2) ErrorException Undefined variable: word (View: /home/vagrant/Code/Laravel/resources/views/test.blade.php)

When I remove $word form the blade view and replace with a static string "test" it displays correctly.

no idea why the blade view can't see the $word varible, any ideas anyone?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2tnEb4I
via IFTTT

Aucun commentaire:

Enregistrer un commentaire