checked
Outputs the html checked attribute.
Description
Compares the first two arguments and if identical marks as checked
Returns (string)
html attribute or empty string
Parameters (3)
- 0. $checked (mixed)
- One of the values to compare
- 1. $current — Optional. (constant) =>
true
- (true) The other value to compare if not just true
- 2. $echo — Optional. (bool) =>
true
- Whether to echo or just return the string
Usage
if ( !function_exists( 'checked' ) ) { require_once ABSPATH . WPINC . '/general-template.php'; } // One of the values to compare $checked = null; // (true) The other value to compare if not just true $current = true; // Whether to echo or just return the string $echo = true; // NOTICE! Understand what this does before running. $result = checked($checked, $current, $echo);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/general-template.php
- function checked( $checked, $current = true, $echo = true ) {
- return __checked_selected_helper( $checked, $current, $echo, 'checked' );
- }