php - php 中缺少类 php_com_dotnet
问题描述
所以我在我的代码中使用了调用 php_com_dotnet:
$word = new COM("word.application");
// Hide MS Word application window
$word->Visible = 0;
//Create new document
$word->Documents->Add();
// Define page margins
$word->Selection->PageSetup->LeftMargin = '2';
$word->Selection->PageSetup->RightMargin = '2';
// Define font settings
$word->Selection->Font->Name = 'Arial';
$word->Selection->Font->Size = 10;
// Add text
$word->Selection->TypeText("TEXT!");
// Save document
$filename = tempnam(sys_get_temp_dir(), "word");
$word->Documents[1]->SaveAs($filename);
// Close and quit
$word->quit();
unset($word);
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=document_name.doc");
// Send file to browser
readfile($filename);
unlink($filename);
我得到了他的错误:
致命错误:未捕获的错误:在 /var/www/clients/client1/web1/web/nordin/save.php:6 中找不到类“COM”堆栈跟踪:在 /var/www/clients/ 中抛出 #0 {main}第 6 行的 client1/web1/web/nordin/save.php
所以我环顾四周,将其添加到我的 php.ini 文件中:
[COM_DOT_NET]
;extension=php_com_dotnet.dll
enable_dl = On
; extension_dir = "ext"
它仍然不起作用,我做错了什么?请帮忙!
编辑
我的文件在 sftp 服务器上,出现如下错误:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
解决方案
扩展名前的分号是注释,表示未启用扩展名。要启用它,您必须删除该分号:
;extension=php_com_dotnet.dll
变成
extension=php_com_dotnet.dll
进行此更改后,您可能需要重新启动 IIS。
推荐阅读
- r - R heatmaply 和 pheatmap 输出
- hadoop - Hadoop中超级用户和超级组的区别
- java - 如何使用 Eclipse IDE 调试命令行编译的 Java .class 文件?
- react-native - 如何使用 React Native 将多张图片的帧显示为循环动画
- html - 超出尺寸的图像
- sql-server - 如何从带有单引号的字符串中逃脱以进行插入?
- apache-kafka - 卡夫卡服务没有出现
- sql - 如何通过 Hive 中数组的总和对数组进行归一化?
- android - 如何将回调从活动传递到片段
- websphere - 是否有任何 API 可以下载 NSF 文件?