Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #8722

Re: Thorny string translation issue.

From Christoph Becker <cmbecker69@gmx.de>
Newsgroups comp.lang.php
Subject Re: Thorny string translation issue.
Date 2013-03-19 01:26 +0100
Organization Aioe.org NNTP Server
Message-ID <ki8bbd$rrk$1@speranza.aioe.org> (permalink)
References <ki87ne$s68$1@news.albasani.net>

Show all headers | View raw


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

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Thorny string translation issue. The Natural Philosopher <tnp@invalid.invalid> - 2013-03-18 23:24 +0000
  Re: Thorny string translation issue. Christoph Becker <cmbecker69@gmx.de> - 2013-03-19 01:26 +0100
    Re: Thorny string translation issue. The Natural Philosopher <tnp@invalid.invalid> - 2013-03-19 09:33 +0000
      Re: Thorny string translation issue. BootNic <bootnic.bounce@gmail.com> - 2013-03-19 07:45 -0400
      Re: Thorny string translation issue. Christoph Becker <cmbecker69@gmx.de> - 2013-03-20 00:56 +0100
  Re: Thorny string translation issue. SwissCheese <swisscheese@cfl.rr.com> - 2013-03-18 20:40 -0400
    Re: Thorny string translation issue. The Natural Philosopher <tnp@invalid.invalid> - 2013-03-19 09:38 +0000
  Re: Thorny string translation issue. Jerry Stuckle <jstucklex@attglobal.net> - 2013-03-19 09:01 -0400
  Re: Thorny string translation issue. "Peter H. Coffin" <hellsop@ninehells.com> - 2013-03-19 07:58 -0500

csiph-web