将以下代码 放到对应的方法的class中(只对当前使用) 或app/index/class.php (前台全局使用) 或app/class.php (全系统全局使用) ``` /** * 关键词标红 * @param type $content 全部内容 * @param type $str 关键词 * @return type */ function get_search($content, $str) { $res = str_ireplace($str, '<span class="red">' . $str . '</span>', $content); return $res; } ``` 使用方法 ``` <?=get_search('所显示的内容', '这里调用关键词' ?> ``` 别忘了style中增加 ``` .red {font-style: normal;color: #c00;} ``` 或者把 `<span class="red">' . $str . '</span>`改成``<font color=``"#ff0000"``>``' . $str . '``</font>``