3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function buildQuery($retrievables, $table, $limit = 0, $conditions = "", $orderCondition = "", $orderDirection = "") { $query = "SELECT $retrievables FROM $table"; // if we have conditions - add them to the query $query .= ($conditions != "" ? " WHERE " . $conditions : ""); // if we have a limit - add it to the query $query .= ($limit != 0 ? " LIMIT " . $limit : ""); // if we have to order the results - add it to the query $query .= ($orderCondition != "" ? " ORDER BY " . $orderCondition . " " . $orderDirection : ""); // first we create a "dictionary" which translates $niceValues that are used throughout the code // to $realValues which are used in the MySQL database // since the $realValues are different in every table - we must account to that switch ($table) { case 'usersTable': $niceValues = array("userID", "userName", "userAge", "userLocation", "userSex", "userIntention", "usersTable"); $realValues = array("uid", "uname", "user_bdate", "user_from", "name", "user_intrest", "nuke_users"); // yeah - the field "name" is really the sex of the user break; case 'articlesTable': $niceValues = array("articleID", "articleTitle", "articleLead", "articleBody", "articlesTable"); $realValues = array("sid", "title", "hometext", "bodytext", "nuke_stories"); break; default: $realValues = array(); } // we then replace $niceValues with $realValues $modifiedQuery = str_ireplace($niceValues, $realValues, $query); return $modifiedQuery; } function getUserInfo($userName, $retrievables = "uid, user_bdate, user_from, uname, moody") { $user = getUserID($userName); //$userID = (is_string($user) ? getUserID($user) : $user); //echo($userID); $query = buildQuery($retrievables, "usersTable", "", "uid=bla"); //echo($query); //$getUserInfo = mysql_query($query); //$gotUserInfo = mysql_fetch_array($getUserInfo); return $query; } print_r(getUserInfo("bla")); ?>
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function getUserID() in /in/aPTUi:33 Stack trace: #0 /in/aPTUi(43): getUserInfo('bla') #1 {main} thrown in /in/aPTUi on line 33
Process exited with code 255.
Output for 5.0.0 - 5.6.28
Fatal error: Call to undefined function getUserID() in /in/aPTUi on line 33
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: getuserid() in /in/aPTUi on line 33
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: getuserid() in /in/aPTUi on line 33
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: getuserid() in /in/aPTUi on line 33