Muhammad Sipra
Muhammad Sipra

Reputation: 846

covert a string to html in php Laravel

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 .

Upvotes: 1

Views: 11260

Answers (3)

Death-is-the-real-truth
Death-is-the-real-truth

Reputation: 72299

You Need to do like below:-

{!! $comment['comment'] !!}

Upvotes: 6

Prabhu Nandan Kumar
Prabhu Nandan Kumar

Reputation: 1255

You can use following syntax also :

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

Or

In the way of laravel as follow :

{!! $comment['comment'] !!}

Upvotes: 2

Exprator
Exprator

Reputation: 27513

{!! html_entity_decode($comment['comment']) !!}

if you are using laravel 5

Upvotes: 1

Related Questions