Re: printing special characters in PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 10:16 AM +0000 7/11/06, Antonio Bassinger wrote:
>Dear ALL,
>
>I've an binary file with special (non-printable) characters including '<'
>'/' & '>'. I retrieve this file from the database, into a variable
>$binaryFILE.
>
>I then copy the content to a temporary file, opened with handle $handle :
>
>
>if (!fwrite($handle, $binaryFILE)) {
>          echo "Failed to copy $bname...";
>      }
>      else
>      {
>          echo "Success";
>      }
>
>The file copies to a file on the filesystem correctly. However, if I try to
>print out the characters of this file on a browser, using
>
>echo $binaryFILE;
>
>the output isn't the same. The characters '<' and '>' and anything included
>within is not printed.
>
>I tried printing line by line, using:
>
>$binaryMS = explode("",$binaryMMS);
>foreach ($binaryFILE as $ii)
>{
> echo $ii;
>}
>
>However, no change in result.
>
>Do I print character by character? I shall appreciate any pointers on this
>problem.
>
>Many Thanks
>Antonio

Antonio:

The reason why you are not seeing the characters is that they are being grabbed-up by the browser as html code. In other words, you are injecting html into your web page.

Take a look at this:

http://www.weberdev.com/htmlentities

Now, pass your content through this function and then display.

tedd



-- 
------------------------------------------------------------------------------------
http://sperling.com  http://ancientstones.com  http://earthstones.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux