PHP is garbled when connecting to Oracle, manual putenv (nls_lang) environment variable after normal!

Source: Internet
Author: User
Tags phpinfo
I have a project, migrating from MySQL to Oracle RAC, the database is UTF8 encoded format, simple connection with PHP out of the Chinese are question marks, Baidu found in the database connection need to specify the connection code as UTF8, I specified the environment variables, And in the test page printed PHP Global environment variables, phpinfo (info_environment), the result is normal. If not specified, the PHP environment variable page does not display Nls_lang variable information, it is still garbled, now there is any way, I have a good dozens of PHP page, should be manually at the beginning putenv (Nls_lang) define it. Ask a master to be able to get the parameters of the environment variable Nls_lang when the PHP service is running. and automatically show success in Info_environment.

Add, I'm centos6.5, I've defined Nls_lang in. bash_profile. But it doesn't seem to work. PHP is 5.6,web server is Nginx 1.9


Reply to discussion (solution)

ORACLE does not have UTF8 only utf-8
You should declare the character set you are using when linking to ORACLE
Only ORACLE 8 and below are required to set environment variables

ORACLE does not have UTF8 only utf-8
You should declare the character set you are using when linking to ORACLE
Only ORACLE 8 and below are required to set environment variables


You're right, but there's no way to set the default character sets, which are not in the PHP connection string as in Java.
$conn = Oci_logon (' Orcl ', ' orcl ', ' 127.0.0.1/orcl ', ' UTF8 '), or putenv ("Nls_lang=american_america,utf8");

Both can be normal. I now just want to and Java like without prior declaration, because my test.php text is UTF8 format, database is also UTF8 format, should be able to automatically match it?

I manually output the system environment variable Nls_lang, the result is empty,
Phpinfo (info_environment);
?>
How can we load the system environment variables in PHP initialization, in other words how to specify PHP environment variables, Bash_profile does not work.

Written $conn = Oci_logon (' Orcl ', ' orcl ', ' 127.0.0.1/orcl ', ' UTF8 '); Is that so much trouble?
Java is the database operation through JDBC, PHP is through the client's
So the latter is going to do more things on the setup.

Well, in fact this company is another software company's products, native MySQL, and later due to the company requirements unified with the Oracle RAC Database, the migration of the past. All right, I'm looking for them. The database connection is written in, and I change it.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.