3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
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: Uncaught Error: Failed opening required 'Conn.php' (include_path='.:') in /in/ULIv0:87 Stack trace: #0 {main} thrown in /in/ULIv0 on line 87
Process exited with code 255.
Output for 8.0.13
Register.php Warning: require(Conn.php): Failed to open stream: No such file or directory in /in/ULIv0 on line 87 Fatal error: Uncaught Error: Failed opening required 'Conn.php' (include_path='.:') in /in/ULIv0:87 Stack trace: #0 {main} thrown in /in/ULIv0 on line 87
Process exited with code 255.
Output for 5.1.3 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.37, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.7, 7.3.32 - 7.3.33, 7.4.33
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.2.11 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.32
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 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.3.11, 4.4.0 - 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.

preferences:
254.84 ms | 401 KiB | 344 Q