3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function comment_retrieve($amount = 0, $username = null, $file = null) { if ($file) { if ($amount > 0) { $querystring_file = ' AND `c_username` = ' . $username; } else { $querystring_file = ' WHERE `c_username` = ' . $username; } } else { $querystring_file = ''; } if ($username) { $querystring_username = ' WHERE `c_username` = ' . $username; } else { $querystring_username = ''; } if ($amount > 0) { $querystring_amount = ' LIMIT ' . $amount; } else { $querystring_amount = ''; } // query $querystring = "SELECT * FROM file_comments" . $querystring_username . $querystring_file . $querystring_amount; return $querystring; } echo comment_retrieve(7,'bob','HJFG');
Output for 4.3.0 - 7.1.0
SELECT * FROM file_comments WHERE `c_username` = bob AND `c_username` = bob LIMIT 7