默认用户名:root
默认密码:root
主机名:localhost
端口:3306
立即学习“PHP免费学习笔记(深入)”;
demo:
<?php $hostName = "localhost"; $usrName = "root"; $passWord = "root"; $port = "3306"; $dbname = "flyingman"; $content = mysqli_connect($hostName,$usrName,$passWord,$dbname,$port); mysqli_set_charset($content,'utf-8'); if(!$content){ die("connect failed!:".mysqli_connect_error()); }else{ echo "connect success!"; } mysqli_close($content);
本地浏览器打开中文乱码,上传到服务器又正常解决方案:在PHP文件开头添加下面这句设置字符集
header("content-type:text/html;charset=utf-8");
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
喜欢就支持一下吧
相关推荐