Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php - htmlspecialchars with unicode

Tags:

php

    $string = "Główny folder grafik<p>asd nc</p>";

echo htmlspecialchars($string);

on live site

G&#322;ówny folder grafik<p>asd nc</p>

on local

Główny folder grafik<p>asd nc</p>

what is problem ? i want when run on live site result look like local

like image 607
Chameron Avatar asked Apr 21 '26 13:04

Chameron


2 Answers

htmlspecialchars() accepts additional parameters -- the third one being the charset.

Try specifying that third parameter.

like image 58
Pascal MARTIN Avatar answered Apr 23 '26 01:04

Pascal MARTIN


You need to add extra parameters to the htmlspecialchars() function. The following should work:

htmlspecialchars($string, ENT_QUOTES, "UTF-8");
like image 27
Christophe Avatar answered Apr 23 '26 01:04

Christophe