note 83895 modified in function.com-load-typelib by mgf
| From: | mgf@php.net | Date: | Tue, 17 Jun 2008 14:30:28 +0000 |
| Subject: | note 83895 modified in function.com-load-typelib by mgf | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-140531@lists.php.net to get a copy of this message | ||
Some libraries load other libraries as part of their functionality. For example Crystal Reports
Object Factory uses the CreateObject() method to create an instance of a Crystal Design RunTime
Application. If you want to use constants defined in the newly loaded library, you will need to
manually register the library - even with com.autoregister_typelib set to true.
<?php
echo 'com.autoregister_typelib = ', ini_get('com.autoregister_typelib'),
PHP_EOL;
$o_CrObjectFactory = New COM('CrystalReports11.ObjectFactory.1');
$o_CrApplication =
$o_CrObjectFactory->CreateObject("CrystalDesignRunTime.Application");
echo 'Will not be defined : ', crOpenReportByDefault, PHP_EOL;
com_load_typelib('CrystalDesignRunTime.Application');
echo 'Will now be defined : ', crOpenReportByDefault, PHP_EOL;
?>
outputs ...
com.autoregister_typelib = 1
Will not be defined :
Notice: Use of undefined constant crOpenReportByDefault - assumed 'crOpenReportByDefault'
in C:\refl.php on line 8
crOpenReportByDefault
Will now be defined : 0
--was--
Some libraries load other libraries as part of there functionality. For example Crystal Reports
Object Factory uses the CreateObject() method to create an instance of a Crystal Design RunTime
Application. If you want to use constants defined in the newly loaded library, you will need to
manually register the library. Even with com.autoregister_typelib set to true.
<?php
echo 'com.autoregister_typelib = ', ini_get('com.autoregister_typelib'),
PHP_EOL;
$o_CrObjectFactory = New COM('CrystalReports11.ObjectFactory.1');
$o_CrApplication =
$o_CrObjectFactory->CreateObject("CrystalDesignRunTime.Application");
echo 'Will not be defined : ', crOpenReportByDefault, PHP_EOL;
com_load_typelib('CrystalDesignRunTime.Application');
echo 'Will now be defined : ', crOpenReportByDefault, PHP_EOL;
?>
outputs ...
com.autoregister_typelib = 1
Will not be defined :
Notice: Use of undefined constant crOpenReportByDefault - assumed 'crOpenReportByDefault'
in C:\refl.php on line 8
crOpenReportByDefault
Will now be defined : 0
http://php.net/manual/en/function.com-load-typelib.php