FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Thorny string translation issue.
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Thorny string translation issue. [message #180786 is a reply to message #180782] Tue, 19 March 2013 00:26 Go to previous messageGo to previous message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma:
Member
The Natural Philosopher wrote:

> I want the user to enter raw text and embedded HTML into a database. No
> trouble with getting it in, but when getting it out, it needs massaging
> for display..
>
> Now I cant find a function in the library that will skip html styles
> like <b>...</b> or <a...></a> code, and yet still tranlsatee e.g. '>' to
> '&gt;' etc etc.

You can strip the tags with strip_tags() (note the $allowable_tags
parameter) and later escape the HTML special characters with
htmlspecialchars() (note the $encoding parameter, which may be necessary
to prevent UTF-7 injection attacks). Simplified:

>>> $str='alpha <b>beta < gamma</b> delta';
>>> htmlspecialchars(strip_tags($str));
'alpha beta &lt; gamma delta'

--
Christoph M. Becker
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Hot list for BA/QA- Load Runner, Software Tester, Business Analyst/ Project Coordinator & SAP Business Object Developer
Next Topic: split array and string from string (trust me it will make sense when you read)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 05:36:45 GMT 2024

Total time taken to generate the page: 0.04225 seconds