2012-05-21 23 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 

और अभी भी वही त्रुटि मिल रही है।

मै मैक पर XAMMP और लिनक्स आधारित वेब होस्टिंग का उपयोग कर रहा हूं।

+4

COM केवल विंडोज़ पर उपलब्ध है। –

उत्तर

112

पीएचपी 5.4.5 से, COM और DotNet php php.ini में COM समर्थन जोड़ने के लिए है core.you में बनी नहीं रह जाता है:

[COM_DOT_NET] 
extension=php_com_dotnet.dll 

अन्यथा आप इसे अपने त्रुटि लॉग में देखेंगे: घातक त्रुटि: कक्षा 'COM' नहीं मिली

एक्सटेंशन विंडोज के लिए PHP 5.4.5 के साथ शामिल है।

+7

यह उत्तर हीरे है। – Petah

+0

डिफ़ॉल्ट रूप से इसे चालू नहीं किया जाता है, हालांकि :( – ZJR

+0

इस उत्तर में 100+ अपवॉट होना चाहिए। करोड़पति उत्तर, इसमें कोई संदेह नहीं है :) – chhameed

4

COM Requirements देखें:

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

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

संबंधित मुद्दे