php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51206 PHP4 works, PHP5 says "this variant has no properties"
Submitted: 2010-03-04 22:48 UTC Modified: 2010-03-13 20:46 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: zelnaga at gmail dot com Assigned:
Status: Not a bug Package: COM related
PHP Version: 5.3.1 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
29 - 5 = ?
Subscribe to this entry?

 
 [2010-03-04 22:48 UTC] zelnaga at gmail dot com
Description:
------------
Test script works, as expected, under PHP4.  Gives nonsensical error under PHP5.

Test script:
---------------
<?php
$registry = new COM('winmgmts:root/DEFAULT:StdRegProv');
$values = new VARIANT();
echo $registry->getBinaryValue(0x80000002,
'SOFTWARE\\Microsoft\\Cryptography\\RNG', 'Seed', $values);
var_dump($values->value);
?>

Expected result:
----------------
From PHP4:

array(80) {
  [0]=>
  int(105)
  [1]=>
  int(144)
  [2]=>
  int(158)
  [3]=>
  int(99)
  [4]=>
  int(155)
  [5]=>
  int(55)
  [6]=>
  int(130)
  [7]=>
  int(185)
  [8]=>
  int(210)
  [9]=>
  int(60)
  [10]=>
  int(182)
  [11]=>
  int(200)
  [12]=>
  int(170)
  [13]=>
  int(52)
  [14]=>
  int(34)
  [15]=>
  int(86)
  [16]=>
  int(17)
  [17]=>
  int(147)
  [18]=>
  int(100)
  [19]=>
  int(212)
  [20]=>
  int(205)
  [21]=>
  int(146)
  [22]=>
  int(243)
  [23]=>
  int(102)
  [24]=>
  int(17)
  [25]=>
  int(159)
  [26]=>
  int(193)
  [27]=>
  int(252)
  [28]=>
  int(189)
  [29]=>
  int(83)
  [30]=>
  int(143)
  [31]=>
  int(51)
  [32]=>
  int(183)
  [33]=>
  int(3)
  [34]=>
  int(48)
  [35]=>
  int(46)
  [36]=>
  int(102)
  [37]=>
  int(73)
  [38]=>
  int(210)
  [39]=>
  int(237)
  [40]=>
  int(13)
  [41]=>
  int(244)
  [42]=>
  int(194)
  [43]=>
  int(117)
  [44]=>
  int(254)
  [45]=>
  int(234)
  [46]=>
  int(166)
  [47]=>
  int(147)
  [48]=>
  int(104)
  [49]=>
  int(192)
  [50]=>
  int(211)
  [51]=>
  int(117)
  [52]=>
  int(50)
  [53]=>
  int(148)
  [54]=>
  int(253)
  [55]=>
  int(148)
  [56]=>
  int(237)
  [57]=>
  int(85)
  [58]=>
  int(70)
  [59]=>
  int(242)
  [60]=>
  int(32)
  [61]=>
  int(159)
  [62]=>
  int(38)
  [63]=>
  int(182)
  [64]=>
  int(211)
  [65]=>
  int(36)
  [66]=>
  int(205)
  [67]=>
  int(115)
  [68]=>
  int(212)
  [69]=>
  int(117)
  [70]=>
  int(40)
  [71]=>
  int(249)
  [72]=>
  int(102)
  [73]=>
  int(67)
  [74]=>
  int(100)
  [75]=>
  int(147)
  [76]=>
  int(236)
  [77]=>
  int(194)
  [78]=>
  int(241)
  [79]=>
  int(28)
}

Actual result:
--------------
From PHP5:

Fatal error: Uncaught exception 'com_exception' with message 'this variant has no properties' in C:\php\test.php:5 Stack trace: #0 C:\php\test.php(5): unknown() #1 {main} thrown in C:\php\test.php on line 5

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-13 20:39 UTC] ksingla@php.net
$variant->type and $variant->value syntax is not supported in PHP5. See http://www.php.net/manual/en/class.variant.php for more details.

Doesn't seem like there is a way to print an array of variants in php5. Bug 35956 also talks about this problem.
 [2010-03-13 20:46 UTC] ksingla@php.net
-Status: Open +Status: Bogus
 [2010-03-13 20:46 UTC] ksingla@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You can use foreach to iterate through variant array. See code below.

variant_get_type($values);
foreach($values as $value)
{
    echo ($value . "\n");
}
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 08:01:30 2024 UTC