__return_null()WP 3.4.0

Simply returns null. Auxiliary function of WordPress.

Designed for use in filters, to not to register a function when you want to return null.

All such helper functions:
__return_false() — returns false.
__return_true() — returns true.
__return_empty_array() — returns an empty: array().
__return_zero() — returns the number 0.
__return_null() — returns NULL.
__return_empty_string() — returns an empty string: ''.

This is an internal function for using it by WP core itself. It's not recommended to use this function in your code.

1 time — 0.000001 sec (speed of light) | 50000 times — 0.00 sec (speed of light) | PHP 7.1.11, WP 4.9.7

No Hooks.


null. Nothing.


__return_null() // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore;



#1 Example of usage

Let's say that we should always return null in the filter 'my_filter'. Then, use this code:

add_filter( 'my_filter', '__return_empty_string' );

The same we can write so:

// anonymous function - php 5.3+
add_filter( 'my_filter', function(){ return null; } );

// or with registering function
add_filter( 'my_filter', 'my_return_function' );
function my_return_function(){
	return null;


Since 3.4.0 Introduced.

Code of __return_null() WP 5.9.3

function __return_null() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
	return null;