找不到类“COM" [英] Class 'COM' not found

查看:30
本文介绍了找不到类“COM"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试在我的脚本中打开一个 word 文档,但我收到了同样的错误.

I've been trying to open a word document in my script, but I get receiving the same error.

 Fatal error: Class 'COM' not found in /Applications/XAMPP/xamppfiles/htdocs/**/**.php on line 3

我的代码:

<?php

$word = new COM("word.application") or die("Unable to instantiate Word"); 

$word->Visible = 1; 


$word->Documents->Open("wordfile.docx");
$temp = $word->Dialogs->Item(228); // returns wdDialogToolsWordCount dialog object
$temp->Execute();   //updates the word count
$numwords = $temp->Words(); //gets the words out of it

echo 'Word count = '.$numwords;

$word->Quit(); 

?>

我尝试更改 php.ini 并从 COM 部分删除分号.

I've tried to change php.ini and remove the semicolons from COM section.

[com]
path to a file containing GUIDs, IIDs or filenames of files with TypeLibs
com.typelib_file = 
allow Distributed-COM calls
com.allow_dcom = true
autoregister constants of a components typlib on com_load()
com.autoregister_typelib = true
register constants casesensitive
com.autoregister_casesensitive = false
show warnings on duplicate constat registrations
com.autoregister_verbose = true 

仍然出现同样的错误.

我在 mac 上使用 XAMMP 和基于 linux 的虚拟主机.

I'm using a XAMMP on mac, and a linux based web hosting.

推荐答案

从 PHP 5.4.5 开始,COM 和 DOTNET 不再内置在 php 核心中.您必须在 php.ini 中添加 COM 支持:

From PHP 5.4.5, COM and DOTNET is no longer built into the php core.you have to add COM support in php.ini:

[COM_DOT_NET]
extension=php_com_dotnet.dll

否则,您将在错误日志中看到:致命错误:找不到类COM"

Otherwise you will see this in your error log: Fatal error: Class 'COM' not found

该扩展包含在适用于 Windows 的 php 5.4.5 中.

The extension is included with php 5.4.5 for Windows.

这篇关于找不到类“COM"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆