3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class MySQLDao { var $dbhost = null; var $dbuser = null; var $dbpass = null; var $conn = null; var $dbname = null; var $result = null; function __construct() { $this->dbhost = Conn::$dbhost; $this->dbuser = Conn::$dbuser; $this->dbpass = Conn::$dbpass; $this->dbname = Conn::$dbname; } public function openConnection() { $this->conn = new mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname); if (mysqli_connect_errno()) echo new Exception("Could not establish connection with database"); } public function getConnection() { return $this->conn; } public function closeConnection() { if ($this->conn != null) $this->conn->close(); } public function getUserDetails($Facebookid) { $returnValue = array(); $sql = "select * from Users where FacebookId='" . $Facebookid . "'"; $result = $this->conn->query($sql); if ($result != null && (mysqli_num_rows($result) >= 1)) { $row = $result->fetch_array(MYSQLI_ASSOC); if (!empty($row)) { $returnValue = $row; } } return $returnValue; } /* public function getUserDetailsWithPassword($email, $userPassword) { $returnValue = array(); $sql = "select id,user_email from users where user_email='" . $email . "' and user_password='" .$userPassword . "'"; $result = $this->conn->query($sql); if ($result != null && (mysqli_num_rows($result) >= 1)) { $row = $result->fetch_array(MYSQLI_ASSOC); if (!empty($row)) { $returnValue = $row; } } return $returnValue; } */ public function registerUser($Facebookid, $firstname, $lastname, $FBpictureURL, $Gender, $UserEmail) { $sql = "insert into Users FacebookId=?, firstname=?, lastname=?, FBpictureURL=?, Gender=?, UserEmail=?"; $statement = $this->conn->prepare($sql); if (!$statement) throw new Exception($statement->error); $statement->bind_param("isssss", $Facebookid, $firstname, $lastname, $FBpictureURL, $Gender, $UserEmail); $returnValue = $statement->execute(); return $returnValue; } } ?> Register.php <?php require("Conn.php"); require("MySQLDao.php"); $Facebookid = htmlentities($_POST["Facebookid"]); $firstname = htmlentities($_POST["firstname"]); $lastname = htmlentities($_POST["lastname"]); $FBPictureURL = htmlentities($_POST["FBPictureURL"]); $Gender = htmlentities($_POST["Gender"]); $UserEmail = htmlentities($_POST["UserEmail"]); $returnValue = array(); $dao = new MySQLDao(); $dao->openConnection(); $userDetails = $dao->getUserDetails($email); if(!empty($userDetails)) { $returnValue["status"] = "Success"; $returnValue["message"] = "User already exists, so Login"; $returnValue["userid"] = "Test"; $returnValue["firstname"] = "Test"; $returnValue["Gender"] = "Test"; $returnValue["FBPictureURL"] = "Test"; echo json_encode($returnValue); return; } $result = $dao->registerUser($Facebookid, $firstname, $lastname, $FBPictureURL, $Gender, $UserEmail); if($result) { $returnValue["status"] = "Success"; $returnValue["message"] = "New User is registered, so Login"; $returnValue["userid"] = "Test"; $returnValue["firstname"] = "Test"; $returnValue["Gender"] = "Test"; $returnValue["FBPictureURL"] = "Test"; echo json_encode($returnValue); return; } $dao->closeConnection(); ?>
Output for 7.2.11, 7.3.0rc3 - 7.3.0rc4
Register.php Warning: require(): open_basedir restriction in effect. File(Conn.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/ULIv0 on line 87 Warning: require(Conn.php): failed to open stream: Operation not permitted in /in/ULIv0 on line 87 Fatal error: require(): Failed opening required 'Conn.php' (include_path='.:') in /in/ULIv0 on line 87
Process exited with code 255.
Output for 5.1.3 - 7.1.7, 7.3.0alpha1 - 7.3.0beta1
Register.php Warning: require(Conn.php): failed to open stream: No such file or directory in /in/ULIv0 on line 87 Fatal error: require(): Failed opening required 'Conn.php' (include_path='.:') in /in/ULIv0 on line 87
Process exited with code 255.
Output for 7.1.20 - 7.2.6
Register.php Warning: require(): open_basedir restriction in effect. File(Conn.php) is not within the allowed path(s): (/tmp:/in) in /in/ULIv0 on line 87 Warning: require(Conn.php): failed to open stream: Operation not permitted in /in/ULIv0 on line 87 Fatal error: require(): Failed opening required 'Conn.php' (include_path='.:') in /in/ULIv0 on line 87
Process exited with code 255.
Output for 5.1.0 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/ULIv0 on line 4 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/ULIv0 on line 5 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/ULIv0 on line 6 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/ULIv0 on line 7 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/ULIv0 on line 8 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/ULIv0 on line 9 Register.php Warning: require(Conn.php): failed to open stream: No such file or directory in /in/ULIv0 on line 87 Fatal error: require(): Failed opening required 'Conn.php' (include_path='.:') in /in/ULIv0 on line 87
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/ULIv0 on line 4 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/ULIv0 on line 5 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/ULIv0 on line 6 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/ULIv0 on line 7 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/ULIv0 on line 8 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/ULIv0 on line 9 Register.php Warning: main(Conn.php): failed to open stream: No such file or directory in /in/ULIv0 on line 87 Fatal error: main(): Failed opening required 'Conn.php' (include_path='.:') in /in/ULIv0 on line 87
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected ';', expecting '(' in /in/ULIv0 on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected ';', expecting '(' in /in/ULIv0 on line 12
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'('' in /in/ULIv0 on line 12
Process exited with code 255.