php - Quote messing Attribute title -
i have snippet this:
echo "<a title='" . $row['title'] . "' />" //and on
now mess when $row['title'] contains this:
- the great's title
- the "great" title
what best procedure retain word in title , not break title anchor tag
my solution not effective using str_replace
ideas handle this?
with the great's title
title, output looks this:
<a title='the great's title' />
here attribute value ends prematurely after great
.
you need escape attribute value properly:
echo "<a title='" . htmlspecialchars($row['title'], ent_quotes) . "' />"
now output looks this:
<a title='the great's title' />
the interpreted attribute value still the great's title
.
the same applies the "great" title
, like:
<a title='the "great" title' />
Comments
Post a Comment