兼容我找不到問題。此代碼可以工作多年,但在重置服務器之後,會顯示此致命錯誤。也許你可以幫助我。謝謝PHP致命錯誤:聲明...必須與
PHP Fatal error: Declaration of styBoxLoadEventArgs::__construct() must be compatible with EventArgs::__construct() in .../modules/sty/events/styBoxLoadEventArgs.php on line 4
代碼:
<?php
class styBoxLoadEventArgs extends EventArgs
{
public $hide = false;
public $box;
public function __construct($box)
{
$this->box = $box;
}
}
?>
這裏是EventArgs的
?php
/**
* EventArgs
*/
abstract class EventArgs
{
public $sender, $senderClass, $senderObject, $event;
protected $items;
/**
* Creates new EventArgs object
*/
abstract public function __construct();
/**
* Returns specified item
*
* @param string item-name
* @return mixed
*/
public function __get($_name)
{
if(!array_key_exists($_name, $this->items))
{
throw new BasicException("Item '" . $_name . "' not found");
}
return $this->items[$_name];
}
/**
* Sets specified item
*
* @param string item-name
* @param mixed value
*/
public function __set($_name, $_value)
{
if(!array_key_exists($_name, $this->items))
{
throw new BasicException("Item '" . $_name . "' not found");
}
$this->items[$_name] = $_value;
}
public function &GetByRef($_key)
{
if(!array_key_exists($_key, $this->items))
{
throw new BasicException("Item '" . $_key . "' not found");
}
return $this->items[$_key];
}
}
類'EventArgs'的構造函數是怎麼樣的? –
擴展類時,構造方法必須與父類構造方法一致。我猜你的父類沒有參數或不同的參數? – purpleninja
EventArgs被定義爲一個抽象類。我現在發佈代碼。也許你有一個想法。謝謝 – schnittstelle