3v4l.org

run code in 300+ PHP versions simultaneously
<?php ob_start(function ($str) { ini_set('pcre.jit', '0'); return preg_replace_callback('~(.)\1{2}\K\1{27,}(?=\1{3})~', fn ($m) => '...' . (strlen($m[0]) + 6) . '*...', $str); }); $str = str_repeat('x', 65_540); $str2 = 'y' . $str; $expectedRes = [['v' => $str], ['v' => $str2]]; echo "expected:\n"; print_r($expectedRes); $sql = 'select v from ( select ? v union all select ? v ) t'; $mysqli = new \mysqli('localhost', 'atk4_test', 'XXXXX', 'atk4_test__data'); $stmt = $mysqli->prepare($sql); $stmt->bind_param('ss', $str, $str2); $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_all(\MYSQLI_ASSOC); echo "\nactual using mysqli driver:\n"; print_r($row); var_dump($row === $expectedRes); // reproduce the same with pdo_mysql driver $pdo = new \PDO('mysql:host=127.0.0.1;dbname=atk4_test__data', 'atk4_test', 'XXXXX'); $stmt = $pdo->prepare($sql); $stmt->bindValue(1, $str); $stmt->bindValue(2, $str); $stmt->execute(); $res = $stmt->fetchAll(\PDO::FETCH_ASSOC); echo "\nactual using PDO driver:\n"; print_r($row); var_dump($row === $expectedRes);
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.15, 8.5.0
expected: Array ( [0] => Array ( [v] => xxx...65540*...xxx ) [1] => Array ( [v] => yxxx...65540*...xxx ) ) Fatal error: Uncaught Error: Class "mysqli" not found in /in/2IHsS:23 Stack trace: #0 {main} thrown in /in/2IHsS on line 23
Process exited with code 255.

preferences:
56.17 ms | 406 KiB | 5 Q