Deprecated: Methods with the same name as their class will not be constructors in a Future version of PHP

Asked

Viewed 3,392 times

1

I have a page in Wordpress that for some time is all blank and only appears the favicon.

I enabled the display of the PHP error message to know what was happening and I got this:

Deprecated: Methods with the same name as their class will not be constructors in a Future version of PHP; Modulebanners has a deprecated constructor in /customers/b/6/0/donnacostura.com.br/httpd.www/wp-content/plugins/module-banners/module_banners.php on line 17

Deprecated: Methods with the same name as their class will not be constructors in a Future version of PHP; Moduleservicos has a deprecated constructor in /customers/b/6/0/donnacostura.com.br/httpd.www/wp-content/plugins/module-services/module_services.php on line 17

Warning: Cannot Modify header information - headers already sent by (output Started at /customers/b/6/0/donnacostura.com.br/httpd.www/wp-content/plugins/module-banners/module_banners.php:17) in /customers/b/6/0/donnacostura.com.br/httpd.www/wp-admin/includes/Misc.php on line 1198

How to solve this?

  • What is your level of knowledge in PHP?

1 answer

2


To begin with, you need to interpret the error messages.

The first two messages say that the constructor using the class name will be removed in future versions of PHP. The goal is to prepare you for future updates to your PHP.

Example (depreciated):

class MinhaClasse
{
    public function MinhaClasse()
    {
        //
    }
}

As it should be:

class MinhaClasse
{
    public function __construct()
    {
        //
    }
}

The last message says that you cannot change the request header because outputs have already been generated for the user.

You can check this change in the header at the place informed by the error message:

/customers/b/6/0/donnacostura.com.br/httpd.www/wp-admin/includes/misc.php on line 1198

It’s probably a redirect: header('Location: ...');.

And as the message itself suggests, the first output generated was in:

/customers/b/6/0/donnacostura.com.br/httpd.www/wp-content/plugins/module-banners/module_banners.php:17

Note that this output is the first message. Once you solve the first problem, your site should go back to normal. If not, it will point out other classes that should be reviewed or new errors/warnings on your website.


@off I advise to focus more on the interpretation of the errors. As I showed you, PHP itself already delivers you "to lick" where they are and what the errors are. Even if you don’t understand some terms of the message, try to understand them by searching for them. This is part of the foundation of learning in whatever language you’re going to program.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.