Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rendering HTML from database table to view blade issue

Tags:

php

laravel-5

I am having a problem by rendering some html stuff from a database table. I have a function that is calling and returning some html content from databse table, when i use {{ }} double curly braces it shows the content on page but as a plain text not rendered as html. After i try to use {!! !!} it does not show anything on page. i don't understand why and what's the solution in this case. My blade page contains the .blade extension as well.

Please advice.

$string = "<h1>Its H1 Tag</h1>";

{{ $string }}
like image 817
syed khawar Avatar asked Jun 20 '16 17:06

syed khawar


2 Answers

It can be displayed by the following code too if above code doesn't work.

@php
 echo $string;
@endphp
like image 186
Muhammad Adnan Avatar answered Sep 22 '22 12:09

Muhammad Adnan


For Laravel Version 5.6.* or higher use single Curley Braces

$string = "<h1>Its H1 Tag</h1>;

{!! $string !!}
like image 35
Matee Gojra Avatar answered Sep 20 '22 12:09

Matee Gojra