[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

PHP, WMI, COM object and getting the array value

Posted on 2011-02-24
3
Medium Priority
?
865 Views
Last Modified: 2012-05-11
This code

      define ( 'CPU_NAME', '.' );

      $obj = new COM ( 'winmgmts:{impersonationLevel=impersonate}//' . CPU_NAME . '/root/cimv2' );

      if ( is_object ( $obj ) )
      {
            $process = $obj->execquery ( "SELECT * FROM Win32_BIOS" );

            if ( $process->count > 0 )
            {
                  foreach($process as $row){
                  	echo"BIOS: $row->bioscharacteristics<br />";
                  }
            }
            else
            {
                  echo 'error';
            }

            $obj = null;
      }
      else
      {
            echo 'no object';
      }

Open in new window


produces an error

Catchable fatal error: Object of class variant could not be converted to string in C:\xampp\htdocs\aa\index.php on line 71

I'm aware of the WMI classes and the property value of the BIOS characteristics as it is an array of integers separated with "," - or maybe just string value of integers with ",". Most of the Win32 classes does not give this error (Win32_Account for example). Caould you guide me how to deal with these kind of situations ?
0
Comment
Question by:Lukasz Chmielewski
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
Learnctx earned 1500 total points
ID: 34977708
I have never done anything with PHP, but as far as doing this in VBScript or PowerShell I would usually join this particular property array into a single string and then use it.
[string]::Join(",",(GWMI -Q "SELECT bioscharacteristics FROM Win32_BIOS").BiosCharacteristics)

Open in new window

I'm assuming in PHP you can do something similar?
0
 
LVL 27

Author Comment

by:Lukasz Chmielewski
ID: 34977721
Thanks for response, I'll try to convert it to PHP and get back to you.
0
 
LVL 27

Author Closing Comment

by:Lukasz Chmielewski
ID: 34987917
Well, partially. Made me code some more to finally get the value into an array.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question