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&#39;s title' /> 

the interpreted attribute value still the great's title.

the same applies the "great" title, like:

<a title='the &quot;great&quot; title' /> 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -