php - 我在代码 {Login-Signup form} 中收到 PHP 已弃用错误
问题描述
我收到以下错误:
代码中有什么错误?
[27-May-2018 20:37:37 UTC] PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; FGMembersite has a deprecated constructor in /home/gurudev/public_html/user/include/fg_membersite.php on line 24
[27-May-2018 20:37:37 UTC] PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; FormValidator has a deprecated constructor in /home/gurudev/public_html/user/include/formvalidator.php on line 66
[27-May-2018 20:37:58 UTC] PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; FGMembersite has a deprecated constructor in /home/gurudev/public_html/user/include/fg_membersite.php on line 24
[27-May-2018 20:37:58 UTC] PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; FormValidator has a deprecated constructor in /home/gurudev/public_html/user/include/formvalidator.php on line 66
[27-May-2018 20:37:58 UTC] PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/gurudev/public_html/user/include/fg_membersite.php:773
Stack trace:
#0 /home/gurudev/public_html/user/include/fg_membersite.php(729): FGMembersite->DBLogin()
#1 /home/gurudev/public_html/user/include/fg_membersite.php(86): FGMembersite->SaveToDatabase(Array)
#2 /home/gurudev/public_html/user/register.php(6): FGMembersite->RegisterUser()
#3 {main}
thrown in /home/gurudev/public_html/user/include/fg_membersite.php on line 773
解决方案
[27-May-2018 20:37:37 UTC] PHP 已弃用:与其类同名的方法在 PHP 的未来版本中将不再是构造函数;FGMembersite 在第 24 行的 /home/gurudev/public_html/user/include/fg_membersite.php 中有一个已弃用的构造函数
这意味着该类的构造函数以 php 在未来版本中不再支持的方式命名。
class FGMembersite{
public function FGMemmbersite() : void{
echo "something";
}
}
class FGMembersite{
public function __construct() : void{
echo "something";
}
}
new FGMembersite();
这两个类都会回显“某事”,不同之处在于第一个构造函数方法在未来的 php 版本中将不再工作,因为它与类本身同名;它必须是 __construct()
它警告你,你的代码可能会破坏这条线。
推荐阅读
- scala - dataframe spark scala take the (MAX-MIN) for each group
- android - 我的应用程序不适用于 android < 5 中的自签名 SSL
- spring - Spring Boot 和 RabbitMQ 异常日志记录
- java - 渐变背景
- angularjs - 如何在 Bonita 的自定义小部件中定义角度 js 过滤器
- hoverfly - Hoverfly 不会在目的地拦截我自己定义的主机
- java - 无法将对象删除到 ArrayList
- wordpress - Docker暴露服务实现dockerized wordpress多站点
- google-apps-script - 如何使用应用程序脚本在环聊聊天机器人中获取用户的位置
- r - 用时间表示为咒语重塑数据