3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Create connection $start = microtime(TRUE); error_log('Connecting'); $connection=mysqli_connect("localhost","******","*****","*****"); error_log('Connection took' . microtime(TRUE) - $start); // Check connection if ($connection == false) { die("ERROR: Could not connect. " .mysqli_connect_error()); } // This SQL statement selects ALL from the table 'Locations' $sql = "SELECT * FROM Notes"; error_log('Running select'); if ($result = mysqli_query($connection, $sql)){ error_log('Select took' . microtime(TRUE) - $start); // If so, then create a results array and a temporary one // to hold the data $resultArray = array(); // Loop through each row in the result set error_log('looping fetch'); while($row = $result->fetch_object()) { error_log('Fetch is running at ' . microtime(TRUE) - $start); // Add each row into our results array $resultArray[] = $row; } // Finally, encode the array to JSON and output the results echo json_encode($resultArray); } error_log('Fetch is done at ' . microtime(TRUE) - $start); // Close connections mysqli_close($connection); error_log('Connection closed at ' . microtime(TRUE) - $start); ?>
Output for 8.0.1 - 8.0.21, 8.1.0 - 8.1.8
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /in/5Jr3N:5 Stack trace: #0 {main} thrown in /in/5Jr3N on line 5 Connecting
Process exited with code 255.
Output for 7.4.0 - 7.4.30
Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /in/5Jr3N on line 6 Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /in/5Jr3N on line 15 Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /in/5Jr3N on line 23 Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /in/5Jr3N on line 30 Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /in/5Jr3N on line 33 Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /in/5Jr3N:5 Stack trace: #0 {main} thrown in /in/5Jr3N on line 5 Connecting
Process exited with code 255.

preferences:
56.07 ms | 409 KiB | 5 Q