3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class dateCalculation { public $use_date; function __construct($date=null) { if(!empty($date)) { $this->$use_date = $date; } else { $this->$use_date = date('Y-m-d H:i:s'); } } public function validNextDrawDate() { $next_valid_date_time_1 = strtotime('this wednesday 20:00'); $next_valid_date_time_2 = strtotime('this saturday 20:00'); if(strtotime($this->$use_date) < $next_valid_date_time_1) { // Past wednesday 20:00 of this week. $appointment_date_time = $next_valid_date_time_1; } else { $appointment_date_time = $next_valid_date_time_2; } echo date('Y-m-d H:i', $appointment_date_time); } } echo date('Y-m-d H:i:s'); $dateCalculation = new dateCalculation(date('Y-m-d H:i:s')); echo $dateCalculation->validNextDrawDate();
based on TqDbm
Output for 7.1.0 - 7.2.0
2015-09-18 19:43:46 Notice: Undefined variable: use_date in /in/rKG6r on line 10 Notice: Undefined variable: use_date in /in/rKG6r on line 20 2015-09-23 20:00
Output for 7.0.0 - 7.0.20
2015-09-18 19:43:46 Notice: Undefined variable: use_date in /in/rKG6r on line 10 Fatal error: Uncaught Error: Cannot access empty property in /in/rKG6r:10 Stack trace: #0 /in/rKG6r(33): dateCalculation->__construct('2015-09-18 19:4...') #1 {main} thrown in /in/rKG6r on line 10
Process exited with code 255.
Output for 5.4.0 - 5.6.28
2015-09-18 19:43:46 Notice: Undefined variable: use_date in /in/rKG6r on line 10 Fatal error: Cannot access empty property in /in/rKG6r on line 10
Process exited with code 255.