3v4l.org

run code in 300+ PHP versions simultaneously
<?php //sql hard in code for now (generated sql normally //var_dump of type shows 'ss' => string(2) "ss" //var dump of $params shows: array(2) { [0]=> string(7) "renault" [1]=> string(20) "Alaskan" } //SQL ERROR : //Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables public function getSomething(string $sql, string $type, array $params): array { $result = array(); $statement = $this->connection->prepare($sql); $sql = "SELECT * FROM housemark WHERE merk LIKE ? AND (model LIKE ?) GROUP BY form ORDER BY form"; if ($statement) { //call_user_func_array(array(&$statement, 'bind_param'), makeValuesReferenced($params)); var_dump(makeValuesReferenced(array("mark1", 'model1'))); //neither of this one works //$statement->bind_param($type, makeValuesReferenced($params)); // $statement->bind_param("ss", makeValuesReferenced(array("renault", 'alaskan'))); if ($statement->execute()) { $statement->store_result(); var_dump($statement); if ($statement->num_rows >= 1) { $statement->bind_result($id, $mark, $model, $form); while ($rij = $statement->fetch()) { $result[] = new Housemark($id, $mark, $model, $form); } } } } var_dump($this->connection->error); return $result; } function makeValuesReferenced(array $arr): array { $refs = array(); foreach ($arr as $key => $value) $refs[$key] = &$arr[$key]; return $refs; }
Output for 8.0.0
Parse error: syntax error, unexpected token "public", expecting end of file in /in/fIHXM on line 13
Process exited with code 255.
Output for 7.3.0 - 7.3.26, 7.4.0 - 7.4.14
Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting end of file in /in/fIHXM on line 13
Process exited with code 255.

preferences:
152.41 ms | 1399 KiB | 50 Q