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"
基础教程推荐
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何替换eregi() 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
