Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP special characters not showing [duplicate]

Can anyone help with with special characters and php.

The following php:

$IHaventReceivedCode = "Je n'ai pas reçu mon code";

is showing as:

Je n'ai pas re�u mon code

I have tried adding to the file at the top:

ini_set('default_charset', 'UTF-8');
header('Content-Type: text/html; charset=UTF-8');

and also to the head tag:

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

However, the character fails to show.

Any ideas?

like image 210
user2183216 Avatar asked Dec 09 '25 00:12

user2183216


2 Answers

Try to convert the document to that encoding. If for example you are using Notepad++ you can do the following:

enter image description here

like image 65
Wallack Avatar answered Dec 11 '25 14:12

Wallack


If your files are in UTF-8... You can try utf8_encode
$IHaventReceivedCode = utf8_encode("Je n'ai pas reçu mon code");

Or decode utf8_decode
$IHaventReceivedCode = utf8_decode("Je n'ai pas reçu mon code");

I'm pretty sure that one of them should change the output...

like image 27
JoDev Avatar answered Dec 11 '25 12:12

JoDev



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!