Problem with Utf8 encoding in Laravel

Asked

Viewed 61 times

1

Guys I’m facing a problem with UTF8 coding, I don’t know what happens. When I print the text through the controller it is correct this way http://prntscr.com/ofcemt.

But when I move the text to the view

return view('pagina_texto', compact('title','textoexemplo'));

Text loses UFT8 encoding and looks like this http://prntscr.com/ofce0t

  • Try printing like this: {!! $textoexemplo !!}

  • Thank you very much friend. God was just that. He would know to tell me the difference between {!! $textfor !! } and the form it was using {{ $texte }} ?

  • In the {!! !!} You save text in the bank with html code that it understands, already in {? }} brings exactly the saved text

1 answer

1


In Laravel you can show exactly the contents of your string with {{ }}

Example if you saved like this:

| campo               |
| <h1>Bem vindo</h1>  |

If you use it like this: {{ $field }}

He’ll show it exactly like this:

 <h1>Bem vindo</h1>

Now if you use it like this: {!! $field !!}

He’ll show it like this:

Welcome

It does the same function as htmlentities php

I hope I’ve helped

  • Thank you very much. I understood the explanation perfectly.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.