PHP is garbled when connecting to ORACLE. it is normal after manual PUTENV (NLS_LANG) environment variable! I have a project that migrates data from MYSQL to ORACLE RAC. the database is in UTF8 encoding format, and the Chinese characters retrieved by simple connections using PHP are question marks, baidu now needs to specify the connection encoding as UTF8 for database connection. I have specified the environment variables and printed the global environment variables in PHP on the test page. phpinfo (INFO_ENVIRONMENT ), the result is normal. If this parameter is not specified, the environment variable page of PHP does not display the variable information of nls_lang. the code is still garbled. how can I use dozens of PHP pages, do you need to manually define PUTENV (NLS_LANG) at the beginning. Please advise me to bring the environment variable nls_lang parameters when the PHP service is running. It is automatically displayed in INFO_ENVIRONMENT.
In addition, I am centos6.5 and have defined nls_lang in. bash_profile. But it does not seem to work. PHP is 5.6, WEB server is nginx 1.9
Reply to discussion (solution)
ORACLE does not have utf8 and only UTF-8 is supported
You should declare the character set used when connecting to ORACLE
Environment variables must be set only for ORACLE 8 and below
ORACLE does not have utf8 and only UTF-8 is supported
You should declare the character set used when connecting to ORACLE
Environment variables must be set only for ORACLE 8 and below
You are right, but is there a way to set the default character set, that is, it is not in the PHP connection string as it is in JAVA?
$ Conn = OCI_Logon ('orcl ', 'orcl', '2017. 0.0.1/orcl ', 'utf8'); or putenv ("NLS_LANG = american_america, UTF8 ");
Both are normal. I just want to avoid declaring it in advance like JAVA, because my TEST. PHP text is in UTF8 format, and the database is also in UTF8 format. Should I be able to automatically match it?
I manually output the system environment variable nls_lang and the result is null,
Phpinfo (INFO_ENVIRONMENT );
?>
How can we load system environment variables during PHP initialization? in other words, how to specify the PHP environment variables does not work for bash_profile.
Write $ conn = OCI_Logon ('orcl ', 'orcl', '192. 0.0.1/orcl ', 'utf8'); is it so troublesome?
Java performs database operations through jdbc, and php operates through the client.
So the latter needs to do more settings.
In fact, this company is a product of another software company, native MYSQL. Later, due to the company's requirements for unified use of oracle rac databases, it migrated to the past .. Okay, I want to find out where their database connection is written, and I can fix it myself.