Web Hosting Offers
See the new scripts recently added to Dynamic Drive. Click here.
Original, practical CSS codes and examples such as CSS menus for your site.
    Search code samples  
 
  Keyword
 
 
 
   
 
 
  Code Samples
 
ASP
CSS
Dhtml
Html
Javascript
PHP
 
   
     LOGIN HERE  
 
Username
Password
Forgot Password
Verify Signup
 
 
 

PHP >> General

How do I check whether a string contains HTML?

Visitor Ratings (0) :

Description
There are two ways you can do it, one is using a regular expression the other is comparing strings.

First the regular expression approach:

if (preg_match("/([\<])([^\>]{1,})*([\>])/i", $string)) {
echo "string contains html";
}

And here is the other approach:

if(strlen($string) != strlen(strip_tags($string)){
echo "string contains HTML";
}



Code
Select All
 Rate this Resource