Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve charset utf8 in PHP?

Tags:

php

I use function htmlspecialchars() in PHP and cyrillic symbols.

I get error:

Message: htmlspecialchars(): charset `utf8' not supported, assuming utf-8

Is there alretnative htmlspecialchars() or solution for this charset?

PHP code:

$text  = htmlspecialchars($text, ENT_QUOTES,$charset);
like image 347
Caur Avatar asked Oct 15 '25 15:10

Caur


1 Answers

Remember to call filter_input(INPUT_GET, 'name', FILTER_SANITIZE_STRING); first if you bring the data from a REQUEST to this arena. This is what you need in order to use htmlspecialchars:

$text = htmlspecialchars($name, ENT_QUOTES, 'UTF-8');
like image 79
Solrac Avatar answered Oct 18 '25 12:10

Solrac



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!