Class #39;COM#39; not found(找不到类“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"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:找不到类“COM"


- PHP Count 布尔数组中真值的数量 2021-01-01
- Laravel 仓库 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01