PHP Fatal error: Declaration of ... MySQLServer :: insert () must be compatible with ... Server :: insert () in /home/lfLvpx/prog.php on line 102
Why does this error occur, and how to correct it?
abstract class Server { public function __construct($token) { if ($token !== $_POST['crm_token']) { http_response_code(401); } else { $this->accept(); } } abstract protected function insert(); ... } class MySQLServer extends Server { protected function insert(mysqli $link, $table, array $required) { $fields = "`".implode("`, `", $required)."`"; $fields_num = count( $required ); $questions = str_repeat( "?,", $fields_num - 1 ) . "?"; $query = "INSERT INTO `$table` ($fields) VALUES ($questions)"; $data = []; foreach( $required as $field ){ $data[] = $_POST[$field]; } $stmt = mysqli_prepare($link, $query ); $types = str_repeat('s', $fields_num ); $stmt->bind_param( $types, ...$data ); $stmt->execute(); } }
abstract protected function prefixName($name);and childpublic function prefixName($name, $separator = ".")..... but something tells me they all have to you - Alex Shimansky