3v4l.org

run code in 300+ PHP versions simultaneously
<?php $classes = array('DateInterval', 'DateTimeImmutable', 'DateTime', 'DateTimeZone'); foreach ($classes as $class){ echo "Signature of $class::_set_state\n"; try{ $rm = new ReflectionMethod($class, '__set_state'); var_dump($rm->getNumberOfParameters()); var_dump($rm->getNumberOfRequiredParameters()); } catch(Exception $e) { echo "$class: " . $e; } } echo "End of param counts for __set_state\n\n"; try { var_export(DateTime::__set_state(array( 'date' => '2017-06-08 05:11:40.907706', 'timezone_type' => 3, 'timezone' => 'UTC', ))); } catch(Error $e) { echo "Couldn't call DateTime::__set_state: " . $e . "\n"; } // DateTime::__set_state(); // would trigger Warning: DateTime::__set_state() expects exactly 1 parameter, 0 given in php shell code on line 1 // needs 2, datefmt and bool, according to docs (not 100% sure) echo "datefmt_set_lenient\n"; $rf = new ReflectionFunction('datefmt_set_lenient'); var_dump($rf->getNumberOfParameters()); var_dump($rf->getNumberOfRequiredParameters());
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Signature of DateInterval::_set_state int(1) int(1) Signature of DateTimeImmutable::_set_state int(1) int(1) Signature of DateTime::_set_state int(1) int(1) Signature of DateTimeZone::_set_state int(1) int(1) End of param counts for __set_state \DateTime::__set_state(array( 'date' => '2017-06-08 05:11:40.907706', 'timezone_type' => 3, 'timezone' => 'UTC', ))datefmt_set_lenient int(2) int(2)
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Signature of DateInterval::_set_state int(1) int(1) Signature of DateTimeImmutable::_set_state int(1) int(1) Signature of DateTime::_set_state int(1) int(1) Signature of DateTimeZone::_set_state int(1) int(1) End of param counts for __set_state \DateTime::__set_state(array( 'date' => '2017-06-08 05:11:40.907706', 'timezone_type' => 3, 'timezone' => 'UTC', ))datefmt_set_lenient int(2) int(2)
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28
Signature of DateInterval::_set_state int(1) int(1) Signature of DateTimeImmutable::_set_state int(1) int(1) Signature of DateTime::_set_state int(1) int(1) Signature of DateTimeZone::_set_state int(1) int(1) End of param counts for __set_state DateTime::__set_state(array( 'date' => '2017-06-08 05:11:40.907706', 'timezone_type' => 3, 'timezone' => 'UTC', ))datefmt_set_lenient int(2) int(2)
Output for 7.3.32 - 7.3.33, 7.4.33, 8.0.13
Signature of DateInterval::_set_state int(1) int(1) Signature of DateTimeImmutable::_set_state int(1) int(1) Signature of DateTime::_set_state int(1) int(1) Signature of DateTimeZone::_set_state int(1) int(1) End of param counts for __set_state DateTime::__set_state(array( 'date' => '2017-06-08 05:11:40.907706', 'timezone_type' => 3, 'timezone' => 'UTC', ))datefmt_set_lenient Fatal error: Uncaught ReflectionException: Function datefmt_set_lenient() does not exist in /in/jEmee:32 Stack trace: #0 /in/jEmee(32): ReflectionFunction->__construct('datefmt_set_len...') #1 {main} thrown in /in/jEmee on line 32
Process exited with code 255.
Output for 7.3.0 - 7.3.31, 7.4.0 - 7.4.32
Signature of DateInterval::_set_state int(1) int(1) Signature of DateTimeImmutable::_set_state int(1) int(1) Signature of DateTime::_set_state int(1) int(1) Signature of DateTimeZone::_set_state int(1) int(1) End of param counts for __set_state DateTime::__set_state(array( 'date' => '2017-06-08 05:11:40.907706', 'timezone_type' => 3, 'timezone' => 'UTC', ))datefmt_set_lenient int(1) int(1)
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33
Signature of DateInterval::_set_state int(0) int(0) Signature of DateTimeImmutable::_set_state int(0) int(0) Signature of DateTime::_set_state int(0) int(0) Signature of DateTimeZone::_set_state int(0) int(0) End of param counts for __set_state DateTime::__set_state(array( 'date' => '2017-06-08 05:11:40.907706', 'timezone_type' => 3, 'timezone' => 'UTC', ))datefmt_set_lenient int(1) int(1)

preferences:
182.73 ms | 402 KiB | 187 Q