Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

covert a string to html in php Laravel

Tags:

html

php

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 .

like image 898
Muhammad Sipra Avatar asked Feb 18 '26 10:02

Muhammad Sipra


2 Answers

You Need to do like below:-

{!! $comment['comment'] !!}
like image 81
Anant Kumar Singh Avatar answered Feb 20 '26 23:02

Anant Kumar Singh


You can use following syntax also :

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

Or

In the way of laravel as follow :

{!! $comment['comment'] !!}
like image 38
Prabhu Nandan Kumar Avatar answered Feb 20 '26 23:02

Prabhu Nandan Kumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!