使用 MySQL strip_tags函数删除 html标签

DELIMITER //
CREATE FUNCTION `strip_tags`($str text) RETURNS text
BEGIN
    DECLARE $start, $end INT DEFAULT 1;
    LOOP
        SET $start = LOCATE("<", $str, $start);
        IF (!$start) THEN RETURN $str; END IF;
        SET $end = LOCATE(">", $str, $start);
        IF (!$end) THEN SET $end = $start; END IF;
        SET $str = INSERT($str, $start, $end - $start + 1, "");
    END LOOP;
END;
//
DELIMITER ;

英文原文:http://stackoverflow.com/questions/7654436/what-is-the-mysql-query-equivalent-of-php-strip-tags

历史搜索记录:

Post a Comment

Your email is never shared. Required fields are marked *

*
*