Building a byte array in PHP with variants?

僤鯓⒐⒋嵵緔 提交于 2019-12-04 11:18:37

(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);

(NOTE: so does leaving VT_ARRAY out of it i.e)

$v = new VARIANT($post);

Prints out 8024. 8024 - 8192 = 12. 12 = VT_VARIANT

Or am I missing something here?

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.

This is from PHP source code (PHP 5.3.3) (might help, I could be way off)

/* Only perform conversion if variant not already of type passed */
if ((ZEND_NUM_ARGS() >= 2) && (vt != V_VT(&obj->v))) {

   /* 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)
   */
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!