How to fix strict standards: override an already defined constructor for a class

This error occurs in PHP 5.4.3, and the solution I found is to hide the errors.

error_reporting(E_ALL ^ E_STRICT);

But I want to fix it, not hide it. Could you explain why this error occurs and how to fix it?

This is mistake:

Strict standards: overriding an already defined constructor for the VisanaObject class in / home / template / public _HTML / project / activecollab / angie / classes / VisanaObject.class.php on line 33

This is the class code:

class VisanaObject {

    /**
    * Object constructor
    *
    * @param void
    * @return Object
    */
    function VisanaObject() {
      $args = func_get_args();

      // Call constructor, with or without args
      if(is_array($args)) {
        call_user_func_array(array(&$this, '__construct'), $args);
      } else {
        $this->__construct();
      } // if
    } // VisanaObject

    /**
    * Construct the VisanaObject
    *
    * @param void
    * @return VisanaObject
    */
    function __construct() {

    } // __construct

  } // VisanaObject
+4
source share
1 answer

PHP. PHP __construct(). __construct, " = " .

,

class foo {
   function foo() { ... this is a constructor }
   function __construct() { .. this is another constructor ... }
}

VisanaObject __construct().

+5

Source: https://habr.com/ru/post/1648559/


All Articles