Logo

7.4K views Asked 29 Dec 2018 in PHP
4

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"

User shakti (9.6K Points)

2 Answers
3
smarterqa (210 Points)

answered 29 Dec 2018

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. 

 


Can you please explain using my code ?  –  shakti 29 Dec 2018
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 .  –  sunnypundir 26 Apr 2019
Add comment

4
priyasharma4005 (4.3K Points)

answered 29 Dec 2018

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. 


Thank you Priyasharma4005. My problem has been solved  –  shakti 29 Dec 2018
Add comment

Your Answer
×
Login Required

You must login to continue.

Login Login with Google
Register