Quick question about PHP variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mshita
Forum Commoner
Posts: 32
Joined: Sat Jul 03, 2004 8:55 pm
Location: Portland, OR
Contact:

Quick question about PHP variables

Post 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.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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.
mshita
Forum Commoner
Posts: 32
Joined: Sat Jul 03, 2004 8:55 pm
Location: Portland, OR
Contact:

Post by mshita »

What do you mean? Sorry, I'm such a newbie when it comes to web app development.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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.
mshita
Forum Commoner
Posts: 32
Joined: Sat Jul 03, 2004 8:55 pm
Location: Portland, OR
Contact:

Post 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!
Post Reply