Annotation of embedaddon/php/ext/com_dotnet/README, revision 1.1.1.1

1.1       misho       1: This is the new php5 COM module.
                      2: 
                      3: It is not 100% backwards compatible with PHP 4 ext/com, but you should not miss
                      4: the "features" that have not been retained.
                      5: 
                      6: This module exposes 3 classes: variant, com and dotnet(*).
                      7: com and dotnet classes are descendants of the variant class; the only
                      8: difference between the three are their constructors.  Once instantiated, the
                      9: module doesn't make a distinction between them.
                     10: 
                     11: COM errrors are mapped to exceptions; you should protect your COM code using
                     12: the try..catch construct if you want to be able to handle error conditions.
                     13: 
                     14: Be warned that due to the way the ZE2 currently works, exceptions are only
                     15: "armed" at the time they are detected, but do not "detonate" until the end of
                     16: the statement.  So, code like this:
                     17: 
                     18:   $obj->foo[43]->bar();
                     19: 
                     20: Where the foo[43] access triggers an exception will continue to call the bar()
                     21: method on a null object and cause a fatal php error.
                     22: 
                     23: Default properties and array access:
                     24: 
                     25: $obj = new COM("...");
                     26: $obj[1]->foo();
                     27: 
                     28: The code above will use the type information for the object to determine its
                     29: default property and then access it.  In PHP 4, it was hard-coded to use the
                     30: "Items" member, which was wrong.
                     31: 
                     32: The default property will also be used by the casting support to determine the
                     33: value for the object.
                     34: 
                     35: Variants:
                     36: 
                     37: This implementation of COM takes a simpler approach than the PHP 4 version;
                     38: we only map a few native types to COM and vice-versa, leaving the more complex
                     39: things as variants.  This allows greater consistency of data when passing
                     40: parameters to and from COM objects (no data will be lost).  In addition, a
                     41: large number of the variant API has been mapped to PHP space so that you can
                     42: use it for working with the special variant decimal, currency and date time
                     43: types.  This could be used as a replacement for the bcmath extension, for
                     44: example.
                     45: 
                     46: You can use the new object casting hook to for a php-native representation of
                     47: a variant object:
                     48: 
                     49: $a = new variant(4);
                     50: $b = new variant(6);
                     51: $c = variant_add($a, $b);
                     52: echo $c; // outputs 10 as a string, instead of Object
                     53: 
                     54: Sample Script:
                     55: 
                     56: <?php
                     57: $word = new COM("word.application");
                     58: print "Loaded Word, version {$word->Version}\n"; 
                     59: $word->Visible = 1; 
                     60: $word->Documents->Add(); 
                     61: $word->Selection->TypeText("This is a test..."); 
                     62: $word->Documents[1]->SaveAs("Useless test.doc"); 
                     63: $word->Quit(); 
                     64: ?>
                     65: 
                     66: TODO:
                     67: 
                     68: - documentation
                     69: 
                     70: * dotnet support requires that you have the mscoree.h header from the .net sdk
                     71:   when you build the module.

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>