ginerjm Posted September 3, 2014 Share Posted September 3, 2014 So I am doing a script to read some emails coming into an address that I have piped to it. Done this before and had success. Problem now is strip_tags. Trying to remove some spurious html codes in the email the easy way or so I thought. What's happening is this A line that contains an email address such as this: From: <user@domain.com> is being stripped out to this: From: <user@domain.com> I thought that strip_tags would just strip out the < and > chars but it is not. Any ideas? Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted September 3, 2014 Share Posted September 3, 2014 The HTML entities do not come from strip_tags(). Appearently you're also using htmlspecialchars() or htmlentities(). strip_tags() is generally a very poor choice. This function is supposed to remove HTML tags, but it's way too primitive to do that correctly. Chances are it will just mangle the entire input. In your case, for example, it removes the whole e-mail address, which is probably not what you want. Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted September 3, 2014 Share Posted September 3, 2014 The purpose of strip_tags() is to remove HTML and PHP tags from a string. More information can be found here: http://php.net/manual/en/function.strip-tags.php In your case, however, it looks you're running the email address(es) through something like htmlentities() before running strip_tags(). That's where entities like < come from. If you're just looking to remove some specific characters, you could look into using something like str_replace(): http://php.net/manual/en/function.str-replace.php Quote Link to comment Share on other sites More sharing options...
ginerjm Posted September 3, 2014 Author Share Posted September 3, 2014 (edited) The input comes from an email and looking at the raw source I got before I added the strip tags I saw an email address enclosed in < and >. There was no other function applied to this - I simply thought that I could remove the < and > with this function. Apparently I can't Edited September 3, 2014 by ginerjm Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.