By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,526 Members | 1,895 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,526 IT Pros & Developers. It's quick & easy.

controlling what kind of data is returned by PHP

P: n/a
This may be an ignorant question, but does PHP always return text data? I
would like to return binary data from a script that I call, in much the same
way that I get binary data simply by downloading a file. I would like to
call a php file and let it determine what binary data is returned.

Right now, if I try to return a binary string, it seems like the string is
being converted into coded characters , like "%5F" and such

Thanks
B
Jan 15 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Bint wrote:
This may be an ignorant question, but does PHP always return text
data? I would like to return binary data from a script that I call,
in much the same way that I get binary data simply by downloading a
file. I would like to call a php file and let it determine what
binary data is returned.
Right now, if I try to return a binary string, it seems like the
string is being converted into coded characters , like "%5F" and such

Thanks
B
All data is "binary" data. The browser however interprets the data in
different ways depending on the headers that are sent with it. So if the
headers say it is an image, the browser will try to display it as an image.
Jan 15 '08 #2

P: n/a
Paul Lautman wrote:
Bint wrote:
>This may be an ignorant question, but does PHP always return text
data? I would like to return binary data from a script that I call,
in much the same way that I get binary data simply by downloading a
file. I would like to call a php file and let it determine what
binary data is returned.
Right now, if I try to return a binary string, it seems like the
string is being converted into coded characters , like "%5F" and such

Thanks
B

All data is "binary" data. The browser however interprets the data in
different ways depending on the headers that are sent with it. So if the
headers say it is an image, the browser will try to display it as an image.

And if it is text, but with odd characters in it, php MAY decide to turn
that into HTML correct characters, depending on how switches are set I
think.
Jan 16 '08 #3

P: n/a
On 16 Jan, 02:41, The Natural Philosopher <a...@b.cwrote:
Paul Lautman wrote:
Bint wrote:
This may be an ignorant question, but does PHP always return text
data? I would like to return binary data from a script that I call,
in much the same way that I get binary data simply by downloading a
file. I would like to call a php file and let it determine what
binary data is returned.
Right now, if I try to return a binary string, it seems like the
string is being converted into coded characters , like "%5F" and such
Thanks
B
All data is "binary" data. The browser however interprets the data in
different ways depending on the headers that are sent with it. So if the
headers say it is an image, the browser will try to display it as an image.

And if it is text, but with odd characters in it, php MAY decide to turn
that into HTML correct characters, depending on how switches are set I
think.
? new one on me...try this:

<?php
header('Content-Type: image/gif');
$img=file_get_contents('/some/path/some.gif');
print $img;
?>

C.
Jan 16 '08 #4

P: n/a
On Wed, 16 Jan 2008 03:41:41 +0100, The Natural Philosopher <a@b.cwrote:
Paul Lautman wrote:
>Bint wrote:
>>This may be an ignorant question, but does PHP always return text
data? I would like to return binary data from a script that I call,
in much the same way that I get binary data simply by downloading a
file. I would like to call a php file and let it determine what
binary data is returned.
Right now, if I try to return a binary string, it seems like the
string is being converted into coded characters , like "%5F" and such

Thanks
B
All data is "binary" data. The browser however interprets the data in
different ways depending on the headers that are sent with it. So if
the headers say it is an image, the browser will try to display it as
an image.
And if it is text, but with odd characters in it, php MAY decide to turn
that into HTML correct characters, depending on how switches are set I
think.
PHP does not 'turn it into something' unless specifically told so. How is
it you think PHP does this 'to HTML correct characters' alteration?
--
Rik Wasmus
Jan 19 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.