2012-05-21 3 views
24

스크립트에서 단어 문서를 열려고했지만 동일한 오류가 발생합니다.'COM'클래스가 없습니다.

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 섹션에서 세미콜론을 제거하기 위해 노력했습니다.

[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 기반 웹 호스팅을 사용하고 있습니다.

+4

COM은 Windows에서만 사용할 수 있습니다. –

답변

112

는 PHP 5.4.5에서 COM과 DOTNET는 php.ini 파일에서 COM 지원을 추가해야 core.you는 PHP에 내장되지 더 이상 :

[COM_DOT_NET] 
extension=php_com_dotnet.dll 

그렇지 않으면 오류 로그에 다음과 같이 표시됩니다. 치명적 오류 : 'COM'클래스를 찾을 수 없습니다.

Windows 용 PHP 확장 프로그램에 포함되어있는 확장 프로그램입니다.

+7

이 답변은 다이아몬드입니다. – Petah

+0

기본적으로이 기능을 사용하지는 않습니다. ( – ZJR

+0

이 답변에는 100+ upvotes가 있어야합니다. 백만장 자 답변 : 의심의 여지없이 :) – chhameed

4

COM Requirements 참조 :

COM functions are only available for the Windows version of PHP.

.Net support requires PHP 5 and the .Net runtime.