相关疑难解决方法(0)

找不到"COM"类

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

 Fatal error: Class 'COM' not found in /Applications/XAMPP/xamppfiles/htdocs/**/**.php on line 3
Run Code Online (Sandbox Code Playgroud)

我的代码:

<?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(); 

?>
Run Code Online (Sandbox Code Playgroud)

我试图更改php.ini并删除分区中的分号COM.

[com]
path to a file containing GUIDs, IIDs or filenames of files with TypeLibs
com.typelib_file = 
allow Distributed-COM calls …
Run Code Online (Sandbox Code Playgroud)

php xampp

35
推荐指数
2
解决办法
7万
查看次数

标签 统计

php ×1

xampp ×1