3v4l.org

run code in 300+ PHP versions simultaneously
<?php $posts = $posts = [ [ 'data' => [ 'url' => 'https://hashphp.org', 'author_fullname' => 'alvisleet' ] ], [ 'data' => [ 'url' => 'https://hashphp.org', 'author_fullname' => 'alvisleet' ] ] ]; foreach ($posts as $post) { $fetchedurl = $post['data']['url']; $ids = $post['data']['author_fullname']; $fetchedurl = array($fetchedurl); $stmt = $db->prepare("INSERT INTO data ('fetched_url', 'author') VALUES ('?', '?')"); $db->beginTransaction(); $stmt->execute($fetchedurl); $db->commit(); }
Output for 8.0.0 - 8.0.22, 8.1.0 - 8.1.9
Warning: Undefined variable $db in /in/MbfbG on line 23 Fatal error: Uncaught Error: Call to a member function prepare() on null in /in/MbfbG:23 Stack trace: #0 {main} thrown in /in/MbfbG on line 23
Process exited with code 255.
Output for 7.1.25 - 7.1.27, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.30
Notice: Undefined variable: db in /in/MbfbG on line 23 Fatal error: Uncaught Error: Call to a member function prepare() on null in /in/MbfbG:23 Stack trace: #0 {main} thrown in /in/MbfbG on line 23
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught Error: Call to a member function prepare() on null in /in/MbfbG:23 Stack trace: #0 {main} thrown in /in/MbfbG on line 23
Process exited with code 255.

preferences:
31.09 ms | 411 KiB | 5 Q