@ 2020-12-13T20:09:08Z <?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" }
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.1.0 - 8.1.31 , 8.2.0 - 8.2.27 , 8.3.0 - 8.3.15 , 8.4.1 - 8.4.2 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:dark mode live preview
137.41 ms | 407 KiB | 5 Q