bug deprecated php 4 / problems with php7
-
Hi,
this is what our expert says – I hope it helps:The author is using deprecated PHP 4 syntax that will fail after PHP 7.
They need to use proper, defensive syntax that will remain compatible with PHP 4 (if that’s what they are aiming for) while at the same time protecting their client against future site failures. Specifically code like this:
class QuadMenu_Widget extends WP_Widget {
function QuadMenu_Widget() {
$widget_ops = array(‘classname’ => ‘widget_quadmenu_widget’, ‘description’ => esc_html__(‘A widget that displays the menu in the sidebar.’, ‘quadmenu’));
$control_ops = array(‘width’ => 200, ‘height’ => 250, ‘id_base’ => ‘quadmenu_widget’);
parent::__construct(‘quadmenu_widget’, esc_html__(‘QuadMenu Widget’, ‘quadmenu’), $widget_ops, $control_ops);
}needs to be enhanced for full PHP 7+ support to:
class QuadMenu_Widget extends WP_Widget {
function __construct() {
self::QuadMenu_Widget();
}function QuadMenu_Widget() {
$widget_ops = array(‘classname’ => ‘widget_quadmenu_widget’, ‘description’ => esc_html__(‘A widget that displays the menu in the sidebar.’, ‘quadmenu’));
$control_ops = array(‘width’ => 200, ‘height’ => 250, ‘id_base’ => ‘quadmenu_widget’);
parent::__construct(‘quadmenu_widget’, esc_html__(‘QuadMenu Widget’, ‘quadmenu’), $widget_ops, $control_ops);
}As long as a class has a proper PHP 5+ constructor BEFORE the old PHP 4- constructor (using the class name as a method name), PHP7 will suppress the warning “Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP;”
The topic ‘bug deprecated php 4 / problems with php7’ is closed to new replies.