# Encoding special characters in XML for Flash with PHP

**URL:** <https://forum.kirupa.com/t/encoding-special-characters-in-xml-for-flash-with-php/251200>\
**Category:** programming\
**Created:** [February 6, 2008, 7:36am UTC](https://forum.kirupa.com/t/encoding-special-characters-in-xml-for-flash-with-php/251200 "2008-02-06T07:36:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qgeis](https://avatars.discourse-cdn.com/v4/letter/q/76d3ee/32.png) [@Qgeis](https://forum.kirupa.com/u/Qgeis)\
**Post date:** [February 6, 2008, 7:36am UTC](https://forum.kirupa.com/t/encoding-special-characters-in-xml-for-flash-with-php/251200/1 "2008-02-06T07:36:05Z")

</div>

I have an xml file with special characters like single/doubkle quotes, mdashes, ellipses. I need to get these characters converted into number codes like [COLOR=RoyalBlue]“ (left double quote)[/COLOR] for flash to read.

Which PHP function do I use to convert?

```php
<?php

header('Content-Type: text/xml');

$f = $_GET['f'];
$xmlFile = $f.".xml";

$fh = fopen($xmlFile, 'r') or die("Can't open file");
$theXML = fread($fh, filesize($xmlFile));

fclose($fh);

echo htmlspecialchars($theXML, ENT_QUOTES); //THIS IS WHERE I NEED IT TO WORK!!

?>

```
