checked

Outputs the html checked attribute.

Description

(string) checked( (mixed) $checked, (constant) $current = true, (bool) $echo = true ); 

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

  1. if ( !function_exists( 'checked' ) ) { 
  2. require_once ABSPATH . WPINC . '/general-template.php'; 
  3.  
  4. // One of the values to compare 
  5. $checked = null; 
  6.  
  7. // (true) The other value to compare if not just true 
  8. $current = true; 
  9.  
  10. // Whether to echo or just return the string 
  11. $echo = true; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = checked($checked, $current, $echo); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/general-template.php  
  1. function checked( $checked, $current = true, $echo = true ) { 
  2. return __checked_selected_helper( $checked, $current, $echo, 'checked' );