3v4l.org

run code in 300+ PHP versions simultaneously
<?php $old = <<<'NOWDOC' <?php // Connect $link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password') OR die(mysql_error()); // Query $query = sprintf("SELECT * FROM users WHERE user='%s' AND password='%s'", mysql_real_escape_string($user), mysql_real_escape_string($password)); ?> NOWDOC; $new = preg_replace('/mysql_([a-zA-Z_]+)\(/', 'mysqli_$1($GLOBALS[\'link\'], ', $old); $new = str_replace('mysqli_connect($GLOBALS[\'link\'], ', 'mysqli_connect(', $new); $new = str_replace(', )', ')', $new); echo $new;

preferences:
26.96 ms | 405 KiB | 5 Q