Why is my internal encoding ISO-8859-1 when I specified utf-8 in my php.ini file?

In my php.ini file, I included mbstring.internal_encoding = "UTF-8" . (I tried with or without double quotes, capitalized or not.)

However, when I run echo "current internal encoding: ".mb_internal_encoding(); I am still getting ISO-8859-1.

Why is this, and is there anything I can do in the php.ini file to set the internal encoding once and for all?

I am using WAMPserver on a WinXP laptop.

+3
source share
2 answers

As mentioned in the comments, this is because there are usually at least two php.ini files: one for the command line version and one for the Apache plugin. You need to make sure that you are editing the correct one.

This is not an unusual problem, and I have already bitten it.

+3
source

To override the default_charset of your php.ini, use this method, use ini_set ('default_charset', 'Your Charset');

add this code snippet to each php file at the beginning ...

example: index.php

 <?php $server_root = realpath($_SERVER["DOCUMENT_ROOT"]); $config_serv = "$server_root/php/config.php"; include("$config_serv"); ?> 

then create the "php" folder inside your root server and put this file ... this piece of code serves latin1, overriding utf-8 ...

config.php

 <?php ########################################################################## # Server Directive - Override default_charset utf-8 to latin1 in php.ini # ########################################################################## @ini_set('default_charset', 'ISO-8859-1'); ?> 

or this other ... this piece of code is for utf-8 that overlaps latin1 ... Use the first or second to suit your needs ...

config.php

 <?php ########################################################################## # Server Directive - Override default_charset latin1 to utf-8 in php.ini # ########################################################################## @ini_set('default_charset', 'UTF-8'); ?> 
0
source

Source: https://habr.com/ru/post/909243/


All Articles