3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Add the core functions. */ function apply_filters( $hook_name, $value ) { return $value; } function wp_parse_str( $string, &$array ) { parse_str( $string, $array ); /** * Filters the array of variables derived from a parsed string. * * @since 2.3.0 * * @param array $array The array populated with variables. */ $array = apply_filters( 'wp_parse_str', $array ); } function wp_parse_args( $args, $defaults = array() ) { if ( is_object( $args ) ) { $parsed_args = get_object_vars( $args ); } elseif ( is_array( $args ) ) { $parsed_args =& $args; } else { wp_parse_str( $args, $parsed_args ); } if ( is_array( $defaults ) && $defaults ) { return array_merge( $defaults, $parsed_args ); } return $parsed_args; } /** * Run the sample code to validate what happens when $args is null. */ $args = null; $defaults = array( 'foo' => 'bar' ); $args = wp_parse_args( $args, $defaults ); var_dump( $args ); // array(1) { ["foo"]=> string(3) "bar" }
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Deprecated: parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in /in/P9tVH on line 12 array(1) { ["foo"]=> string(3) "bar" }
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 Deprecated: parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in /in/P9tVH on line 12 array(1) { ["foo"]=> string(3) "bar" }
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
array(1) { ["foo"]=> string(3) "bar" }

preferences:
172.17 ms | 402 KiB | 149 Q