Check If A String Is HTML In PHP

1 · Subin Siby · March 8, 2014, 4:15 a.m.
HTML detection can be hard, because HTML is complicated and there aren’t any good 100% parsers for HTML. RegEx won’t help you in detection, so you need something else. The trick to identify HTML which I’m gonna show you is very easy. It’s fast, short and doesn’t use RegEx. You can simply use an if statement to check if a string is HTML or not. Demo PHP’s strip_tags function when given a string, it returns a string that doesn’t have any HTML / PHP characters (according to the manual)....