php strip_tags removing everything
问题 I am using strip tags on user inputs to remove all possible tags but the strip_tags php function is also removing '<' even if not used in a tag. for example some user might use emoticon as such: >.< or <3 or this can even be used when algorithms etc. Are there any solution to allow the '<' on strip tags? 回答1: Problem is in this case $foo = "text >.<text" Try this expression (preg_replace with ims falgs): <\s*\/?[a-z0-9]+(\s*[a-z\-0-9]+)*(\s*[a-z\-0-9]+\="[^"]*")*\s*\/?> @edit: For example: <