note 96503 deleted from function.call-user-func-array by danbrown

From: Date: Tue, 02 Mar 2010 19:38:33 +0000
Subject: note 96503 deleted from function.call-user-func-array by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-166542@lists.php.net to get a copy of this message
Note Submitter: MarkE ---- Following on from "mrextreme at freemail dot hu" using <?php call_user_func_array()?> with <?php array('parent', '__construct')?> generates an E_STRICT warning along the lines of Message: Non-static method B::__construct() cannot be called statically, assuming $this from compatible context D Severity: E_STRICT (running on PHP 5.2.8). Binding to $this seems to work fine. <?php class B { function __construct($x) { echo 'B::B(). ', $x, PHP_EOL; } } class D extends B { function __construct() { $args = func_get_args(); call_user_func_array(array($this, 'parent::__construct'), $args); } } $d = new D('hey'); ?> B::B(). hey (tested with PHP 5.2.8 and 5.3.0RC1).

« previous php.notes (#166542) next »