laravel 5 - Blade file return the code only -


the blade file index.blade.php

@foreach ( $users $user )       <li>{ !! $user['first_name']!! } { !! $user['last_name']!! } { !! $user['location']!! }</li>  @endforeach 

the controller userscontroller , code

class userscontroller extends controller {     public function index() {         $users = [             0 => [                 'first_name' => 'ranjit',                 'last_name'  => 'pradhan',                 'location'   => 'bhubaneswar'             ],             1 => [                 'first_name' => 'rojalin',                 'last_name'  => 'pradhan',                 'location'   => 'angul'             ]         ];          return view( 'admin.users.index', compact('users') );            } } 

and web.php file this

route::get( 'users', [ 'uses' => 'userscontroller@index'] ); 

but cant result li, returning code of blade file.

{ !! $user['first_name']!! } { !! $user['last_name']!! } { !! $user['location']!! } { !! $user['first_name']!! } { !! $user['last_name']!! } { !! $user['location']!! } 

where problem ? did mistake ? learner.

your blade syntax not valid. remove spaces between { , !!.

<li>{{ $user['first_name'] }} {{ $user['last_name'] }} {{ $user['location'] }}</li> 

and {!! !!} meant unescaped content, e.g. html. should use {{ }} vast majority of time html entities escaped.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -