mysql_connect() Difference between localhost and 127.0.0.1
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Now I have a config file as follows: <?php return array( 'server'=>'localhost', 'username'=>'root', 'password'=>'123456', 'dbname'=>'duxiu', 'charset'=>'utf8' ); I'm cunfused about the time it spends when I using tow methods to connect mysql follows: 1. <?php class Mysql{ private $conn; public function __construct($c){ $this->conn=mysql_connect($c['server'],$c['username'],$c['password'],true) or die("连接出错"); mysql_select_db($c['dbname'],$this->conn); if(isset($c['charset'])){ mysql_query("set names ".$c['charset'],$this->conn); } } } $c