WordPress at a glance

__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: ''.

✈ 1 time = 0.000001s = speed of light | 50000 times = 0.00s = speed of light PHP 7.1.11, WP 4.9.7

No Hooks.

Return

null. Null value.

Usage

__return_null();

Examples

#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;
}

Code of __return_null: wp-includes/functions.php VER 4.9.8

<?php
function __return_null() {
	return null;
}

Related Functions

From tag: __return (helper functions)

More from category: Helper Functions

No comments
    Hello, !     Log In . Register