473,325 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

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
Jan 15 '08 #1
4 1267
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lawrence | last post by:
I had some code that worked fine for several weeks, and then yesterday it stopped working. I'm not sure what I did. Nor can I make out why it isn't working. I'm running a query that should return 3...
14
by: Xavier Décoret | last post by:
I would like to know if there is for python's classes an equivalent of the operator= that can be overidden. Let's say I have >>> a=A() and I want to write >>> a=5 and I want this to change...
21
by: Cigar | last post by:
I am developing a program for a client. She runs a shop where her clients bring in items for sale or short term buyback. Development of the program has been going great but she's mentioned that...
8
by: Andrey Mosienko | last post by:
We are using PostgreSQL about two years beginning from version 7.0. I have one question about starting postmaster: Is there way to detach it from the controlling terminal under FreeBSD? My...
0
by: RWC | last post by:
Hi! I'm having some trouble controlling how the XP Packaging Wizard installs my applications. In 97, there were options to replace older, never or always, if there was a file conflict. Now...
9
by: gold | last post by:
Hello all, I want know abt wht kind of datastructures using both C & C++ internally. Some were said heap, others said tree anyone can explain brief?
1
by: Holger (David) Wagner | last post by:
Hi there, we have an application which is built with several ASCX controls some of which contain form elements (e.g. Textboxes, Buttons etc.) For example: in the top section (one...
8
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
2
by: beargrease | last post by:
I'm kind of comfortable with basic joins, but a current project requires a complex query of many tables. The GROUP_CONCAT(DISTINCT ...) function has been very useful as returning my values as comma...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.