(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

com_print_typeinfoPrint out a PHP class definition for a dispatchable interface


com_print_typeinfo(variant|string $variant, ?string $dispatch_interface = null, bool $display_sink = false): bool

The purpose of this function is to help generate a skeleton class for use as an event sink. You may also use it to generate a dump of any COM object, provided that it supports enough of the introspection interfaces, and that you know the name of the interface you want to display.

Elenco dei parametri


variant should be either an instance of a COM object, or be the name of a typelibrary (which will be resolved according to the rules set out in com_load_typelib()).


The name of an IDispatch descendant interface that you want to display.


If set to true, the corresponding sink interface will be displayed instead.

Valori restituiti

Restituisce true in caso di successo, false in caso di fallimento.

Vedere anche:

add a note

User Contributed Notes 2 notes

csaba at alum dot mit dot edu
19 years ago
com_print_typeinfo is really useful if you're trying to figure out what properties and methods you have access to. For example, I might do:

= new COM("Shell.Application");

The first line shows me the class of the object (what VBScript calls 'typename'), in my case IShellDispatch4. It's frequently the case that if you plunk that in as the second argument to com_print_typeinfo, you get way more methods/properties coming back. Thus:

= new COM("Shell.Application");
com_print_typeinfo($oExplorer, "IShellDispatch4");

Furthermore, you might get additional functions listed if you try lower number suffixes (or not). At any rate, it would be useful for PHP to have a typename function like VBScript does. For example, if you iterate through the Windows of $oExplorer you get both IE and Explorer windows and typename is the easy way to differentiate between them. Here's what I'm using:

function typeName($objCOM) {
if (empty(
$objCOM)) return "no COM object";
if (
gettype($objCOM)!="object") return "not a COM object";
$typeInfo = ob_get_contents();
$pattern = "/^\\s*class (.*) \\{/";
if (!(
$matchCnt = preg_match($pattern, $typeInfo, $aMatch))) return "Not found";

Csaba Gabor from Vienna
Richard Lynch
17 years ago
In my particular version of PHP, the second and third arguments are not, in fact, optional.

Passing in '' for both, however, yielded a bucketful of information.

To Top