當前位置:首頁 » 編程語言 » php的com組件

php的com組件

發布時間: 2024-12-28 06:17:01

php中有個com組件,它裡面都有哪些屬性和方法可以調用呢

先到PHP.INI中打開COM選項,com.allow_dcom = true


PHP 5.4.5後,com/dotnet 模塊已經成了單獨的擴展,所以需要在PHP.ini中配置extension=php_com_dotnet.dll,如果PHP VERSION<5.4.5 則不需要。否則的話,可能就是報錯 Fatal error: Class 'COM' not found 了


配置方法為:只需在擴展列表裡添加extension=php_com_dotnet.dll即可

另外需要了解的是,COM組件雖然也是DLL擴展,但它不是PHP擴展,所以把Senc.dll拷貝到php/ext 目錄,然後在PHP.INI里載入是錯誤的,PHP也不認識它


配置完畢後可以測試下,語句為

$word=newCOM("word.application")ordie("UnabletoinstanciateWord");
print"LoadedWord,version{$word->Version} ";

上面語句本機必須安裝了office才可以

openoffice的為:

$obj=newCOM("com.sun.star.ServiceManager")ordie("UnabletoinstanciateWord");

⑵ 求急送50元Q幣或紅包 php調用COM組件 報錯 想把word格式轉成html格式。。。

$word=new COM("word.application") or die("無法啟動COM組件"); //or 前面需要空格
另外,注意com組件功能只支持windows 版本的php

⑶ 如何用PHP生成word文檔

PHP 生成 word 文檔,可以考慮以下兩類辦法:
1. 利用 windows 系統提供的 com組件。
這種方法的原理,是使用 php 的調用 com 組件功能函數,如果系統里安裝過 office 的伺服器,就可以調用 word.application 。

2. 利用PHP將內容寫入doc文件之中。
這種方法,難分為兩種,一種是生成mht格式寫入word,另一種是編寫純 HTML 格式寫入word。這種方法是基於 word 對 html 的良好支持。

⑷ 釋放COM組件php

$sm=new COM("com.sun.star.ServiceManager");
$d=$sm->createInstance("com.sun.star.frame.Desktop");

...
$d->terminate();//關閉
$sm->dispose();//關閉

⑸ php能夠調用C或C++寫的.dll文件嗎 - PHP進階討論

可以我寫過一個調用SAP BO的COM,要調用必須先安裝好COM組件的,在注冊表查出組件名字(如果你不清楚組件名字的話)我把我寫過的函數給你看看
/**
* 載入COM組件
*/
private function createCompanyObject() {
$company = false;
try {
$company = new COM("SapBobsCom.Company");//這樣就可以獲取COM組件了
} catch(Exception $e) {
$this->errorMsg = $e->getMessage();
}
return $company;
}

⑹ 如何用PHP調用自己編寫的COM組件

首先寫ActiveX Dll:

新建一個VB6工程,ActiveX Dll將工程命名為P_test,類名為c_test ,類的文件內容如下:

Option Explicit

Private MyscriptingContext As scriptingContext

Private MyApplication As Application

Private MyRequest As Request Private MyResponse As Response

Private MyServer As Server

Private MySession As Session Public

Sub OnStartPage(PassedscriptingContext As scriptingContext)

Set MyscriptingContext = PassedscriptingContext

Set MyApplication = MyscriptingContext.Application

Set MyRequest = MyscriptingContext.Request

Set MyResponse = MyscriptingContext.Response

Set MyServer = MyscriptingContext.Server

Set MySession = MyscriptingContext.Session

End Sub

Public Sub OnEndPage()

Set MyscriptingContext = Nothing

Set MyApplication = Nothing

Set MyRequest = Nothing

Set MyResponse = Nothing

Set MyServer = Nothing

Set MySession = Nothing

End Sub

Public Function Test_Number(num) As Variant

If num 0 Then Get_Number_Attrib = 1

If num = 0 Then Get_Number_Attrib = 0

End Function

編譯生成p_test.dll文件

注冊

提示符下運行:regsvr32 p_test.dll

編寫php文件,test.php4代碼如下:

<?php

$b=new COM("p_test.c_test");

$a=$b->Test_Number(-454);

echo $a;

?>

可能碰到的問題是,編譯工程時通不過,要將Microsoft Active Server Pages Object Library引用進來,具體實現"Project->References"找到改庫,並勾上 。

熱點內容
php獲取瀏覽器 發布:2025-03-11 09:03:31 瀏覽:876
安卓常駐後台需要什麼許可權 發布:2025-03-11 08:58:26 瀏覽:180
綠源電動車威牛是什麼配置 發布:2025-03-11 08:47:34 瀏覽:9
wps加密文件密碼忘記 發布:2025-03-11 08:36:49 瀏覽:46
可編程渲染管線 發布:2025-03-11 08:35:23 瀏覽:454
一般人手機設置密碼會是什麼 發布:2025-03-11 08:27:19 瀏覽:415
緩存電視劇軟體 發布:2025-03-11 08:26:26 瀏覽:134
安卓怎麼下載ios14 發布:2025-03-11 08:25:50 瀏覽:566
軟體調試源碼 發布:2025-03-11 08:24:59 瀏覽:488
剪輯視頻怎麼配置解說 發布:2025-03-11 08:24:23 瀏覽:264