3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ExtendsDateTime extends DateTime { public $onConstruct; public function __construct($value, $tz = null) { parent::__construct($value, $tz); $this->onConstruct = true; } public static function createFromFormat($format, $datetime, $timezone = null) { return parent::createFromFormat($format, $datetime); } } $date = ExtendsDateTime::createFromFormat('Y-m-d', '2014-02-14'); var_dump($date instanceof ExtendsDateTime); echo "onConstruct\n"; var_dump($date->onConstruct);
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
Deprecated: Return type of ExtendsDateTime::createFromFormat($format, $datetime, $timezone = null) should either be compatible with DateTime::createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null): DateTime|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/LqeX2 on line 9 bool(true) onConstruct NULL
Output for 8.0.0 - 8.0.30
bool(true) onConstruct NULL
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.3.33, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
bool(false) onConstruct Notice: Undefined property: DateTime::$onConstruct in /in/LqeX2 on line 18 NULL
Output for 7.3.32, 7.4.26
bool(false) onConstruct NULL

preferences:
138.71 ms | 410 KiB | 5 Q