3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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.4.38 - 7.1.0
<h2>Login</h2><form method="post" action="/in/papAH" 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.2.3 - 5.4.37
Warning: ini_set() has been disabled for security reasons in /in/papAH on line 3 Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /in/papAH:3) in /in/papAH on line 61 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/papAH:3) in /in/papAH on line 61 <h2>Login</h2><form method="post" action="/in/papAH" 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.2.2
Warning: ini_set() has been disabled for security reasons in /in/papAH on line 3 Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /in/papAH:3) in /in/papAH on line 61 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/papAH:3) in /in/papAH on line 61 <h2>Login</h2> Notice: Undefined index: SCRIPT_NAME in /in/papAH 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/papAH on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/papAH 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/papAH on line 11
Process exited with code 255.