简体   繁体   English

PHP中的PDO实施问题

[英]PDO implementation issue in PHP

I want to know why does this code work: 我想知道为什么此代码有效:

$conn = new PDO("mysql:host=localhost;dbname=university;charset=utf8","root","",
    array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));

while this one doesn't: 而这个没有:

$conn = new PDO("mysql:host = localhost;dbname=university;charset = utf8","root","");

I have problem on that utf8 section. 我在utf8部分有问题。 Second code showed me ??? 第二个代码向我展示了??? as result but first one worked properly. 结果,但是第一个正常工作。 Both should work properly but... 两者都应该正常工作,但是...

The difference are the spaces near the two "=". 区别在于两个“ =”附近的空格。

You need to erase them. 您需要删除它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM