3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo { public function __toString() { return 'stringable'; } } $inputs = [null, false, true, 0, 1, new Foo()]; foreach ($inputs as $input) { $sfi = new SplFileInfo($input); print("-----\n"); var_export($input); print("\n"); var_export($sfi->getPathname()); print("\n"); var_export($sfi->getPath()); print("\n"); }
Output for 8.2.0 - 8.2.31, 8.3.0 - 8.3.32, 8.4.1 - 8.4.23, 8.5.0 - 8.5.8
Deprecated: SplFileInfo::__construct(): Passing null to parameter #1 ($filename) of type string is deprecated in /in/JcZaf on line 12 ----- NULL '' '' ----- false '' '' ----- true '1' '' ----- 0 '0' '' ----- 1 '1' '' ----- \Foo::__set_state(array( )) 'stringable' ''
Output for 8.1.0 - 8.1.34
Deprecated: SplFileInfo::__construct(): Passing null to parameter #1 ($filename) of type string is deprecated in /in/JcZaf on line 12 ----- NULL '' '' ----- false '' '' ----- true '1' '' ----- 0 '0' '' ----- 1 '1' '' ----- Foo::__set_state(array( )) 'stringable' ''
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
----- NULL '' '' ----- false '' '' ----- true '1' '' ----- 0 '0' '' ----- 1 '1' '' ----- Foo::__set_state(array( )) 'stringable' ''

preferences:
126.79 ms | 1530 KiB | 4 Q