3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Conditions{ function __construct($min,$max){ $this->max = $max; $this->min = $min; } function getMaxTemperature(){ return $this->max; } function getMinTemperature(){ return $this->min; } } $conditions_week = array(new Conditions(5,10),new Conditions(-5,3)); echo "Forecast this week:\n"; foreach($conditions_week as $k=>$conditions) { $varMin = "day".($k+1)."min"; $varMax = "day".($k+1)."max"; $$varMin = $conditions->getMinTemperature(); $$varMax = $conditions->getMaxTemperature(); ?> <tr> <th><?php echo "Max : ". $conditions->getMaxTemperature() . "\n"; ?></th> <th><?php echo "Min : ". $conditions->getMinTemperature() . "\n"; ?></th> </tr> <?php } echo "day1min : " . $day1min; echo '<br>'; echo "day1max : " . $day1max; echo "<hr>"; echo "day2min : " . $day2min; echo '<br>'; echo "day2max : " . $day2max;
Output for 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Deprecated: Creation of dynamic property Conditions::$max is deprecated in /in/vX5bW on line 5 Deprecated: Creation of dynamic property Conditions::$min is deprecated in /in/vX5bW on line 6 Deprecated: Creation of dynamic property Conditions::$max is deprecated in /in/vX5bW on line 5 Deprecated: Creation of dynamic property Conditions::$min is deprecated in /in/vX5bW on line 6 Forecast this week: <tr> <th>Max : 10 </th> <th>Min : 5 </th> </tr> <tr> <th>Max : 3 </th> <th>Min : -5 </th> </tr> day1min : 5<br>day1max : 10<hr>day2min : -5<br>day2max : 3
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
Forecast this week: <tr> <th>Max : 10 </th> <th>Min : 5 </th> </tr> <tr> <th>Max : 3 </th> <th>Min : -5 </th> </tr> day1min : 5<br>day1max : 10<hr>day2min : -5<br>day2max : 3

preferences:
159.31 ms | 404 KiB | 295 Q