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