PHP buffer problem

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
handras
Forum Newbie
Posts: 6
Joined: Wed Aug 15, 2007 4:43 am

PHP buffer problem

Post by handras »

Hi,

I would like make a buffer into different type variables (int2, int4, uint2 etc.) with PHP and i will send on socket for a server application.

example:
I have variables:

Code: Select all

$this->ConnectionId = new VARIANT (-1,VT_I2);
$this->LastOpCode = new VARIANT (65535,VT_UI2);
....
I need a buffer [ConnectionId,LastOpCode,...]


I don't know how can i begin this problem.
Please, give me any idea.
Thank You in advance,

Andras
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Create the VARIANT class, and the VT_* defines. :?
handras
Forum Newbie
Posts: 6
Joined: Wed Aug 15, 2007 4:43 am

Post by handras »

Ok, but i need one buffer. I don't know , how can i interlacing my variables.
The server waiting only one string but i have many variables .

Sorry, but i have used general PHP command.

Please, help me ! :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Do you understand how this "buffer" needs to be composed, data structure-wise?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

I'm not exactly sure what you are after handras, but maybe pack() and unpack() could prove useful in this VARIANT class of yours. There may be other ways to limit binary data types in PHP, but I'm not aware of them.

Maybe something like:

Code: Select all

list($this->data) = unpack("ivalue", pack("i", $value));
handras
Forum Newbie
Posts: 6
Joined: Wed Aug 15, 2007 4:43 am

Post by handras »

Thanks, I can use the pack and unpack.
Post Reply