Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-了解self::_construct()调用_Php_Wordpress - Fatal编程技术网

PHP-了解self::_construct()调用

PHP-了解self::_construct()调用,php,wordpress,Php,Wordpress,我遇到一个Wordpress小部件,看起来像这样 class my_widget extends WP_Widget { function my_widget() { return self::__construct(); } function __construct() { // Some code here ... } } add_action( 'widgets_init', create_function( '', "return regist

我遇到一个Wordpress小部件,看起来像这样

class my_widget extends WP_Widget {

   function my_widget() { return self::__construct(); }

   function __construct() {
     // Some code here
     ...
   }
}

add_action( 'widgets_init', create_function( '', "return register_widget('my_widget');" ) );

创建对象时将调用_construct()。my_widget()函数提供了哪些帮助或功能?真的需要吗?与类同名的函数有什么意义吗?

看起来与PHP4兼容。。。
我想说这段代码很奇怪。

这只是提供了PHP4的向后兼容性,没有其他功能


对于PHP4,
my_widget
是构造函数方法,因此它必须显式调用
\u construct

谢谢。这是有道理的。