php5升php7遇到的问题
浏览量:167
Uncaught Error: Call to a member function init() on null 。
其实在init()函数中,有extension_loaded("mysql"),即加载mysql扩展导致的,需要改为mysqli,不过后面的mysql操作函数都需要改成mysqli的对应类型。
2.Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP;
PHP OOP使用和类名相同的方法名作为构造方法,是 PHP4 的写法,PHP 5中同时支持__construct和类同名方法,但__construct方法具有优先性。
PHP 7开始使用和类名相同的方法名作为构造方法会报E_DEPRECATED级别的错误,提示在未来版本中会彻底抛弃类同名方法作为构造函数。但程序仍然会正常执行。
3.Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP)
在php7中,MYSQL_ASSOC不再是一个常量,将 MYSQL_ASSOC改为MYSQLI_ASSOC,意思是mysqli的方式提取数组,而不再是mysql 。
原因:mysql_fetch_arrayhan函数转为mysqli_fetch_array,参数没有修改
4.汉字显示为???(问号)
mysqli_query($conn,'set names utf8');在使用mysqli_query()查询数据的时候,最好指定字符的编码


感谢支持与鼓励~