如何解决PHP弃用警告类扩展了WP_Widget {
我在我的wordpress网站上收到了不赞成使用的PHP警告,其中指出...与类相同名称的方法在将来的PHP版本中将不再是构造函数; video_widget具有不推荐使用的构造函数。
它指向我下面粘贴的第5行;
class video_widget extends WP_Widget {
/** constructor -- name this the same as the class above */
function video_widget() {
parent::WP_Widget(false,$name = 'Video Widget');
}
/** @see WP_Widget::widget -- do not rename this */
function widget($args,$instance) {
extract( $args );
$title = apply_filters('widget_title',$instance['title']);
$message = $instance['message'];
?>
<?php echo $before_widget; ?>
<?php if ( $title )
echo $before_title . $title . $after_title; ?>
<div class="omc-video-container">
<?php echo $message; ?>
</div>
<?php echo $after_widget; ?>
<?php
}
我确实尝试将第一行更改为
function __construct()
但这使我的网站无法访问。
只是想知道最好的进行方式是什么?
欢呼声, 安德鲁
解决方法
想通了...:)
公共函数__construct(){
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。