Home >Backend Development >PHP Tutorial >How to detect whether a string contains html code in php

How to detect whether a string contains html code in php

WBOY
WBOYOriginal
2016-07-25 08:51:361307browse
  1. function has_html($string){

  2. if(strlen($string) != strlen(strip_tags($string))){
  3. return true;
  4. }
  5. return false;
  6. }

  7. var_dump(has_html("This string doesn't have any html"));

  8. var_dump(has_html("This string has a
    line break"));

复制代码


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn