I am pulling ChassisTypes in W32_SystemEnclosure from WMI with PHP. ChassisTypes is an enumerated, interger-valued array that indicates what type of chassis the computer is (Desktop, Notebook, Laptopt, etc). When echoing or printing the type, I receive the following message:
Recoverable fatal error : Object of class variant could not be converted to string
To work with WMI, you must add extension=php_com_dotnet to php.ini
<?php
$WbemLocator = new COM ("WbemScripting.SWbemLocator");
$WbemServices = $WbemLocator->ConnectServer('localhost', 'root\\cimv2');
$enclosure = $WbemServices->execQuery("Select * from Win32_SystemEnclosure");
foreach($enclosure AS $key){
$type = $key->ChassisTypes;
echo $type;
}
?>
I have tried to settype() the output but I receive the same message. Is there a way to display the results of the ChassisTypes?