controlling what kind of data is returned by PHP

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
grande news [ Di, 15 Januar 2008 22:12 ] [ ID #1908605 ]

Re: controlling what kind of data is returned by PHP

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.
Paul Lautman [ Di, 15 Januar 2008 22:21 ] [ ID #1908606 ]

Re: controlling what kind of data is returned by PHP

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.
Courtney [ Mi, 16 Januar 2008 03:41 ] [ ID #1909668 ]

Re: controlling what kind of data is returned by PHP

On 16 Jan, 02:41, The Natural Philosopher <a... [at] b.c> wrote:
> 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.
colin.mckinnon [ Mi, 16 Januar 2008 14:33 ] [ ID #1909706 ]

Re: controlling what kind of data is returned by PHP

On Wed, 16 Jan 2008 03:41:41 +0100, The Natural Philosopher <a [at] b.c> wrote:

> 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
luiheidsgoeroe [ Sa, 19 Januar 2008 02:30 ] [ ID #1912076 ]
PHP » comp.lang.php » controlling what kind of data is returned by PHP

Vorheriges Thema: php+fastcgi on Apache
Nächstes Thema: Commands out of sync error