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

4
(5.7K Views)

×

Please Login or Register to process.

I am using the Question2Answer  QA application. Currently, I am using Question2Answer  QA version 1.8.2. 

When I installed Q2A-Blog-Post-Plugin-master on the QA application it gave an error.

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; qa_layer_1_from_blog_admin_php has a deprecated constructor in qa\qa-include\qa-base.php(720) : eval()'d code on line 22
of C:\xampp\htdocs\qa\qa-plugin\blog-post/blog-admin.php

 There is an error with the Q2A Blog Post Plugin master.

The 22  line code is here - 

class qa_html_theme_layer extends qa_html_theme_base {

var $plugin_directory;

var $plugin_url;

function qa_html_theme_layer($template, $content, $rooturl, $request)

{

global $qa_layers;

$this->plugin_directory = $qa_layers['Blog Settings']['directory'];

$this->plugin_url = $qa_layers['Blog Settings']['urltoroot'];

qa_html_theme_base::qa_html_theme_base($template, $content, $rooturl, $request);

}

How can I remove this error from the Q2A Blog Post Plugin master? I tried a lot of ways but I didn't get any solution regarding "Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP"

asked 29 Dec 2018 in PHP by shakti(9.1K Points)

Share

2 Answers
answered 29 Dec 2018 by smarterqa(210 Points)
3

As you know that PHP 7 had been launched. If you are using PHP5 version then you need to change small thing related to your solution. 

deprecated means 

Have you notice the depreciated word in your error -

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

 

 

The means of deprecated that it will be removed in the future. So understand the PHP7 concepts, 

In PHP 5, you never seen the function like.__construct()

 . 

Change the function like.__construct() . You need to use __construct().

Understand this and remove your QA BLOG post error. 

 


Comment
Can you please explain using my code ?
commented 29 Dec 2018 by shakti
Thanks for sharing this valuable information about the error - Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP This is solved .
commented 26 Apr 2019 by sunnypundir

answered 29 Dec 2018 by priyasharma4005(4.1K Points)
4

First, navigate your error file - 

qa>qa-plugins>blog-post>blog-admin.php

Jump to the line 22 . 

Use __construct  with the same name as your class :

class qa_html_theme_layer extends qa_html_theme_base {

var $plugin_directory;

var $plugin_url;

function -qa_html_theme_layer($template, $content, $rooturl, $request)

{

global $qa_layers;

$this->plugin_directory = $qa_layers['Blog Settings']['directory'];

$this->plugin_url = $qa_layers['Blog Settings']['urltoroot'];

qa_html_theme_base::qa_html_theme_base($template, $content, $rooturl, $request);

}

I have changed - 

function qa_html_theme_layer($template, $content, $rooturl, $request)

To 

function _qa_html_theme_layer($template, $content, $rooturl, $request)

Hope it will help. 


Comment
Thank you Priyasharma4005. My problem has been solved
commented 29 Dec 2018 by shakti

Related Questions :-

Your Answer

You can post your answer after login..