1

I have a string, I want it to covert HTML as I print it to my blade.php file.

String is like

"<a href=\"http://localhost/myProject/shop/Tom-Shop/MjNzaGFkb3c=\">Tom</a>"

I have following code in my blade for output

<div class="commentText w100">
  <p >{{$comment['comment']}}</p>
</div>

but i code get executed same string comes to the paragraph, I want to print anchor tag should get printed,

Note: I have tried php htmlentities() for this purpose and do R&D as much as i can but nothing worked for me .

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
Muhammad Sipra
  • 806
  • 2
  • 11
  • 27

3 Answers3

6

You Need to do like below:-

{!! $comment['comment'] !!}
Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
2

You can use following syntax also :

<?php echo $comment['comment']; ?>

Or

In the way of laravel as follow :

{!! $comment['comment'] !!}
Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
Prabhu Nandan Kumar
  • 1,205
  • 12
  • 22
1
{!! html_entity_decode($comment['comment']) !!}

if you are using laravel 5

Exprator
  • 26,992
  • 6
  • 47
  • 59