Page 1 of 1
Quick question about PHP variables
Posted: Sun Jul 04, 2004 4:21 pm
by mshita
Can a variable hold non-ASCII character (more like binary information).
Let's say I need 0x0F, 0x4A, and 0x12 stored in a variable $var. Can I then do echo $var? I don't care if the information is not viewable on the screen, as long as their are in the php file sent to the client side and can be read by the client application.
Posted: Sun Jul 04, 2004 4:24 pm
by markl999
Don't see why not as long as you send the correct header("Content-type: for the type of data the binary info represents.
Posted: Sun Jul 04, 2004 4:26 pm
by mshita
What do you mean? Sorry, I'm such a newbie when it comes to web app development.
Posted: Sun Jul 04, 2004 4:32 pm
by markl999
Well if you just echo out binary data to a browser, the browser will just display it as is. For the browser to 'use an external application' to view the data then you need to tell it what type of content it is. For example you couldn't just echo out raw pdf data and expect acroread to open up and display it, you'd need to send a header("Content-type: application/pdf"); which tells the browser it's about to receive some pdf data.
</bad explanation>
http://php.net/header has some more information on it all.
Posted: Sun Jul 04, 2004 4:36 pm
by mshita
Ah, I see what you mean. That no concern to me since I'm not using a browser. I'm writing a wireless Java application that's running on mobiles. So the application knows exactly what it is getting as long as the PHP script manages to echo out binary information
Thanks!