Title: htmlspecialchars xhtml validation
Last modified: August 18, 2016

---

# htmlspecialchars xhtml validation

 *  [sparkio](https://wordpress.org/support/users/sparkio/)
 * (@sparkio)
 * [20 years, 9 months ago](https://wordpress.org/support/topic/htmlspecialchars-xhtml-validation/)
 * I have a site which is using wordpress to imput items into the database but I
   have written a php page myself which is pulling out info from post_content which
   all works fine.
 * At present I have the code
 * —————-
 * $biogtext = htmlspecialchars($biogitem[‘post_content’]);
 * // Paragraphs and line breaks
    $biogtext = ereg_replace(“\r\n”, “\n”, $biogtext);
   $biogtext = ereg_replace(“\r”, “\n”, $biogtext); $biogtext = ereg_replace(“\n\
   n”, ”, $biogtext); $biogtext = ereg_replace(“\n”, ‘‘, $biogtext);
 * echo “$biogtext”;
 * —————-
 * This all works fine but if I want to use tags such as strong’ etc… in wordpress,
   they are outputted as such.
 * If I remove the htmlspecialchars part of the code, then the tags work, but it
   doesn’t validate. I know what htmlspecialchars does and why this is happening.
   I just don’t know how to fix it so I can use the tags (‘strong”em’) in wordpress,
   and it validates too.
 * I hope this is clear and someone can shed light on this.
 * Many Thanks

The topic ‘htmlspecialchars xhtml validation’ is closed to new replies.

## Tags

 * [htmlspecialchars](https://wordpress.org/support/topic-tag/htmlspecialchars/)
 * [validate](https://wordpress.org/support/topic-tag/validate/)
 * [xhtml](https://wordpress.org/support/topic-tag/xhtml/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [sparkio](https://wordpress.org/support/users/sparkio/)
 * Last activity: [20 years, 9 months ago](https://wordpress.org/support/topic/htmlspecialchars-xhtml-validation/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
