0

I have a table in the database contains html codes , i want to append those codes like html in my blade page , but when use

{{ $question->qst_body }}

the result will be some HTML codes are written in plain text how i can disply like html code , for example when i have in database

 $question->qst_body  =  <b>hello world<b> 

The result must be :

hello world

not :

hello world

Anouar
  • 27
  • 4

2 Answers2

2

Change {{ $question->qst_body }} to {!! $question->qst_body !!}

0

I’m not completely clear what you’re asking, but is the answer that you want to use unescaped text?

{!! $question->qst_body !!}

Will do that – but it comes with caution. Do not output information that the user has given you without checking it first. If they are giving you HTML (or maybe Markdown), make sure to use strip_tags() (and more) on it first, as you’re opening up the door for an attack here.

See the Laravel docs for more and heed their warning:

Be very careful when echoing content that is supplied by users of your application. Always use the escaped, double curly brace syntax to prevent XSS attacks when displaying user supplied data.

Zoe Edwards
  • 12,999
  • 3
  • 24
  • 43