问题描述
我正在尝试使用在PHP中构建字节数组>。但是,我似乎无法使其正常运行。以下是示例代码:
I am trying to build a byte array in PHP using Variants. However, I can't seem to make it work. Here's a sample code:
$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);
$ie->Navigate2("http://host/web/echo_request.php",0,'',$v) ;
代码产生错误:
我尝试了来自
任何帮助都将不胜感激!
Any help is greatly appreciated!
推荐答案
(使用PHP 5.3.2)
不仅是VT_ARRAY吗? (或空类型)
(with PHP 5.3.2)
Wouldn't it be just VT_ARRAY? (or empty type)
$post = array (ord('p'),ord('='),ord('1'));
$v = new VARIANT($post, VT_ARRAY);
print variant_get_type($v);
(注意:将VT_ARRAY排除在外也是如此)
(NOTE: so does leaving VT_ARRAY out of it i.e)
$v = new VARIANT($post);
打印出8024。8024-8192 =12。12 = VT_VARIANT
Prints out 8024. 8024 - 8192 = 12. 12 = VT_VARIANT
还是我在这里缺少什么?
Or am I missing something here?
如果要使用VT_UI1,则必须分别创建变体,即
If you want to use VT_UI1 you'll have to create the variants individually i.e
$v = new VARIANT(ord('p'), VT_UI1);
但是我假设您想要第一种方法。
But I'm assuming you're wanting the first way.
这是来自PHP源代码(PHP 5.3.3)(可能有帮助,我可能相距较远)
This is from PHP source code (PHP 5.3.3) (might help, I could be way off)
/* If already an array and VT_ARRAY is passed then:
- if only VT_ARRAY passed then do not perform a conversion
- if VT_ARRAY plus other type passed then perform conversion
but will probably fail (origional behavior)
*/
这篇关于在PHP中使用变体构建字节数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!