selected()
selected( mixed $selected, mixed $current = true, bool $echo = true )
输出html选定属性。
Outputs the html selected attribute.
说明(Description)
比较前两个参数,如果选定的标记相同
参数(Parameters)
参数 | 类型 | 说明 |
---|---|---|
$selected | (mixed) | 要比较的值之一 |
$current | (mixed) | (true)要比较的其他值(如果不只是true) |
$echo | (bool) | 是回显还是只返回字符串 |
源码(Source)
/** * Outputs the html selected attribute. * * Compares the first two arguments and if identical marks as selected * * @since 1.0.0 * * @param mixed $selected One of the values to compare * @param mixed $current (true) The other value to compare if not just true * @param bool $echo Whether to echo or just return the string * @return string html attribute or empty string */ function selected( $selected, $current = true, $echo = true ) { return __checked_selected_helper( $selected, $current, $echo, 'selected' ); }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
1.0.0 | wp-includes/general-template.php | 13 | 10 |
笔记(Notes)
例子
selected() 为WP2原创文章,链接:https://www.wp2.cn/functions/selected/