3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); ini_set('display_errors', 'On'); Class login { //protected $mod_id; //protected $mod_name; //protected $mod_password; //protected $mod_type; private $logged_status = false; //private $con = $this->db_connect(); public $status_message = ""; function __construct() { $this->runApplication(); //$this->mod_id = null; //$this->mod_name = null; //$this->mod_password = null; //$this->mod_type = null; } private function validate_inputs() { if (!empty($_POST['user_name']) && !empty($_POST['user_password'])) { return true; } elseif (empty($_POST['user_name'])) { $this->status_message = "Username field was empty."; } elseif (empty($_POST['user_password'])) { $this->status_message = "Password field was empty."; } // default return return false; } private function page_login_form() { if ($this->status_message) { echo $this->status_message . "<br/><br/>"; } echo '<h2>Login</h2>'; echo '<form method="post" action="' . $_SERVER['SCRIPT_NAME'] . '" name="loginform">'; echo '<label for="login_input_username">Username</label> '; echo '<input id="login_input_username" type="text" name="user_name" required /> '; echo '<label for="login_input_password">Password</label> '; echo '<input id="login_input_password" type="password" name="user_password" required /> '; echo '<input type="submit" name="login" value="Log in" />'; echo '</form>'; } public function get_login_status() { return $this->logged_status; } private function verify_password_and_login() { return true; } public function runApplication() { //session_start(); $this->page_login_form(); } private function logout() { $_SESSION = array(); //session_destroy(); $this->logged_in = false; $this->status_message= "You were just logged out."; } } $application = new login(); ?>
Output for 5.2.3 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
<h2>Login</h2><form method="post" action="/in/ZojH6" name="loginform"><label for="login_input_username">Username</label> <input id="login_input_username" type="text" name="user_name" required /> <label for="login_input_password">Password</label> <input id="login_input_password" type="password" name="user_password" required /> <input type="submit" name="login" value="Log in" /></form>
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.2
<h2>Login</h2> Notice: Undefined index: SCRIPT_NAME in /in/ZojH6 on line 42 <form method="post" action="" name="loginform"><label for="login_input_username">Username</label> <input id="login_input_username" type="text" name="user_name" required /> <label for="login_input_password">Password</label> <input id="login_input_password" type="password" name="user_password" required /> <input type="submit" name="login" value="Log in" /></form>
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/ZojH6 on line 11
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 T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/ZojH6 on line 11
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/ZojH6 on line 11
Process exited with code 255.

preferences:
249.21 ms | 401 KiB | 353 Q