• Register
Welcome to Smarter QA, Questions, Answers Community
Welcome to Smarter QA, where you can ask questions and receive answers from other members of the community. Ask anything that you want. Guests Posting are allowed.
+3 votes
214 views

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 given 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 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 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"

in PHP by Expert (3.1k points) 8 17

2 Answers

+2 votes

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 have seen the function like.__construct()

 . 

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

Understand this and remove your QA BLOG post error. 

by (190 points) 1
Can you please explain using my code ?
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 .
+2 votes

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. 

by (1.3k points) 1 4 11
Thank you Priyasharma4005. My problem has been solved
...