An array of bytes?

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
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

An array of bytes?

Post by kaisellgren »

Hi,

How would I construct an array of bytes with VARIANT (http://fi.php.net/manual/en/class.variant.php) for a .NET module I have?

Code: Select all

$arr = array();
$v = new VARIANT($arr,VT_ARRAY | VT_UI1);
I have tried this (and plenty of other approaches), but it/they didn't work: Fatal error: Uncaught exception 'com_exception' with message 'Variant type conversion failed: Type mismatch.

Does anyone have ideas?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: An array of bytes?

Post by Weirdan »

I guess you either use variant or byte array - they are not the same. Have you tried passing simple php string where byte array is expected?
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: An array of bytes?

Post by kaisellgren »

Weirdan wrote:I guess you either use variant or byte array - they are not the same. Have you tried passing simple php string where byte array is expected?
What is a byte array in PHP? An array that has bytes? Well that does not work either.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: An array of bytes?

Post by Weirdan »

kaisellgren wrote:What is a byte array in PHP?
The closest php has to byte array is string, plain old string.
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: An array of bytes?

Post by kaisellgren »

Weirdan wrote:
kaisellgren wrote:What is a byte array in PHP?
The closest php has to byte array is string, plain old string.
It has the same results: Fatal error: Uncaught exception 'com_exception' with message 'Variant type conversion failed: Type mismatch.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: An array of bytes?

Post by Weirdan »

Well, from what I read on the web your best bet would be VT_BYREF|VT_UI1.
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: An array of bytes?

Post by kaisellgren »

Weirdan wrote:Well, from what I read on the web your best bet would be VT_BYREF|VT_UI1.
Produces the same mismatch error. =/
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: An array of bytes?

Post by Weirdan »

Code: Select all

 
$arr = "\0\1\2";
$v = new VARIANT($arr, VT_ARRAY|VT_UI1);
 
seems to not throw any exceptions, don't know if it actually what is needed.
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: An array of bytes?

Post by kaisellgren »

Weirdan wrote:

Code: Select all

 
$arr = "\0\1\2";
$v = new VARIANT($arr, VT_ARRAY|VT_UI1);
 
seems to not throw any exceptions, don't know if it actually what is needed.
Fatal error: Uncaught exception 'com_exception' with message 'Error [0x80070057] The parameter is incorrect.

The reason why I need this is, because a component requires it.

Take a look at this:

Code: Select all

$ie = new COM("InternetExplorer.Application");
 
$ie->Visible = true;
$ie->Height    = 500 ;
$ie->Width     = 700 ;
 
$post = array (ord('p'),ord('='),ord('1')) ;
$v = new VARIANT($post, VT_ARRAY|VT_UI1); 
 
//postdata need to be array of byte
 
$ie->Navigate2("http://host/web/echo_request.php",0,'',$v);
Post Reply