selected()动态判断select的选项设置为选中

目录

描述

For use in select form fields.
Compares two given values (for example, a saved option vs. one chosen in a form) and, if the values are the same, adds the selected attribute to the current option tag.

selected() 描述

用法

<?php selected( $selected, $current, $echo); ?>

selected() 用法

参数

$selected

(mixed) (必填) One of the values to compare.

默认值: None

$current

(mixed) (可选) The other value to compare if not just true.

默认值: true

$echo

(boolean) (可选) Whether to echo or just return the string.

默认值: true

selected() 参数

源文件

selected() 函数的代码位于 wp-includes/general-template.php.

selected() 源文件