当前位置首页 > 百科> 正文

com(COM 类)

2019-10-06 00:47:18 百科

com(COM 类)

COM 类提供了一个将 (D)COM 组件整合到 PHP 脚本中的框架。

基本介绍

  • 外文名:com
  • 性质:科学
  • 类别:计算机
  • 属于:编程

方法

string COM::COM( string module_name [, string server_name [, int codepage]] )
COM 类构造函式。参数: module_name 被请求组件的名字或 class-id。
server_name DCOM 伺服器的名字,组件在此伺服器上被取用。如果是 NULL,则假定是 localhost。想要允许 DCOM,必须将 php.ini 中的 com.allow_dcom设为 TRUE
codepage 指定用于将 PHP 字元串(php-strings)转换成 UNICODE 字元串(unicode-strings)的代码页,反之亦然。可用的值为 CP_ACPCP_MACCPCP_OEMCPCP_SYMBOLCP_THREAD_ACP, CP_UTF7CP_UTF8

COM 示例

// 启动 word
$word = new COM("word.application") or die("Unable to instanciate Word");
print "Loaded Word, version {$word->Version}\n";
//将其置前
$word->Visible = 1;
//打开一个空文档
$word->Documents->Add();
//随便做些事情
$word->Selection->TypeText("This is a test...");
$word->Documents[1]->SaveAs("Useless test.doc");
//关闭 word
$word->Quit();
//释放对象
$word->Release();
$word = null;
声明:此文信息来源于网络,登载此文只为提供信息参考,并不用于任何商业目的。如有侵权,请及时联系我们:baisebaisebaise@yeah.net