0

I have a string from the database, which has the html tag inside it. everything is the result of the process of CKEditor.

I tried several ways but it didn't work

`$data_from_db = <strong> this is title </strong>`

what I hope is the this is title are printed in bold on the web. but what appears is still <strong> this is title </strong>

  • try using single quotes between the string, and then just echo the variable. – Lucas Arbex Sep 10 '19 at 14:25
  • Thank you for help. This successfully displays the results. previously I used {{$ variable}} in the blade.php file, and it didn't work. after I print using normal php echo it works – Hoiril Mochtar Sep 10 '19 at 14:36
  • To make it work on a blade file using Laravel just follow Vrian7 answer below. – Lucas Arbex Sep 10 '19 at 14:37
  • you are right party ring, and sorry for that. so do I have to delete my posts? I'm a new user of stackoverflow so I don't really understand.. – Hoiril Mochtar Sep 10 '19 at 15:04

2 Answers2

5

If you want render HTML use

{!! $yourvar !!}

into your .blade file

Vrian7
  • 588
  • 2
  • 6
  • 14
  • Thank before. the code is functioning as it should, but there is something strange about the output. there is a sign `{` at the beginning and at the end – Hoiril Mochtar Sep 10 '19 at 14:39
  • Please show your code. Don't you added doble {{! !!}} like this?, its just one { and two ! – Vrian7 Sep 10 '19 at 14:43
  • 1
    You're right, apparently I entered the wrong code. I write `{{!! $ variable !!}}` thank you very much for the answer. very helpful – Hoiril Mochtar Sep 10 '19 at 14:57
0

you can use html_entity_decode for this

From php.net

html_entity_decode() is the opposite of htmlentities() in that it converts HTML entities in the string to their corresponding characters.

source: https://www.php.net/manual/en/function.html-entity-decode.php

mo999dev
  • 33
  • 7