3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!function_exists('str_contains')) { function str_contains(string $haystack, string $needle): bool { return '' === $needle || false !== strpos($haystack, $needle); } } if (!function_exists('str_ends_with')) { function str_ends_with(string $haystack, string $needle): bool { return '' === $needle || ('' !== $haystack && 0 === \substr_compare($haystack, $needle, -\strlen($needle))); } } if (!function_exists('str_starts_with')) { function str_starts_with(string $haystack, string $needle): bool { return 0 === \strncmp($haystack, $needle, \strlen($needle)); } } $methods = [ 'str_contains', 'str_starts_with', 'str_ends_with', ]; $types = [ 'string' => 'test', 'int' => 1, 'float' => 1.23, 'null' => null, 'true' => true, 'false' => false, 'object' => new StdClass(), 'array' => [], ]; $result = []; foreach ($methods as $method) { foreach ($types as $type => $val) { foreach (['first' => [$val, 'test'], 'second' => ['test', $val]] as $firstSecond => $args) { try { $res = $method(...$args); } catch (Error $e) { $res = 'Fatal error triggered'; } $result[$method][$type][$firstSecond] = $res; } } } var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /in/m8OIn on line 53 Deprecated: str_contains(): Passing null to parameter #2 ($needle) of type string is deprecated in /in/m8OIn on line 53 Deprecated: str_starts_with(): Passing null to parameter #1 ($haystack) of type string is deprecated in /in/m8OIn on line 53 Deprecated: str_starts_with(): Passing null to parameter #2 ($needle) of type string is deprecated in /in/m8OIn on line 53 Deprecated: str_ends_with(): Passing null to parameter #1 ($haystack) of type string is deprecated in /in/m8OIn on line 53 Deprecated: str_ends_with(): Passing null to parameter #2 ($needle) of type string is deprecated in /in/m8OIn on line 53 array ( 'str_contains' => array ( 'string' => array ( 'first' => true, 'second' => true, ), 'int' => array ( 'first' => false, 'second' => false, ), 'float' => array ( 'first' => false, 'second' => false, ), 'null' => array ( 'first' => false, 'second' => true, ), 'true' => array ( 'first' => false, 'second' => false, ), 'false' => array ( 'first' => false, 'second' => true, ), 'object' => array ( 'first' => 'Fatal error triggered', 'second' => 'Fatal error triggered', ), 'array' => array ( 'first' => 'Fatal error triggered', 'second' => 'Fatal error triggered', ), ), 'str_starts_with' => array ( 'string' => array ( 'first' => true, 'second' => true, ), 'int' => array ( 'first' => false, 'second' => false, ), 'float' => array ( 'first' => false, 'second' => false, ), 'null' => array ( 'first' => false, 'second' => true, ), 'true' => array ( 'first' => false, 'second' => false, ), 'false' => array ( 'first' => false, 'second' => true, ), 'object' => array ( 'first' => 'Fatal error triggered', 'second' => 'Fatal error triggered', ), 'array' => array ( 'first' => 'Fatal error triggered', 'second' => 'Fatal error triggered', ), ), 'str_ends_with' => array ( 'string' => array ( 'first' => true, 'second' => true, ), 'int' => array ( 'first' => false, 'second' => false, ), 'float' => array ( 'first' => false, 'second' => false, ), 'null' => array ( 'first' => false, 'second' => true, ), 'true' => array ( 'first' => false, 'second' => false, ), 'false' => array ( 'first' => false, 'second' => true, ), 'object' => array ( 'first' => 'Fatal error triggered', 'second' => 'Fatal error triggered', ), 'array' => array ( 'first' => 'Fatal error triggered', 'second' => 'Fatal error triggered', ), ), )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
60.37 ms | 409 KiB | 8 Q