php中缺少类php\u com\u dotnet
因此,我在代码中使用了php_com_dotnet调用:php中缺少类php\u com\u dotnet,php,com,Php,Com,因此,我在代码中使用了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->LeftMargi
$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);
我得到了他的错误:
致命错误:未捕获错误:在第6行的/var/www/client1/web1/web/nordin/save.php中未找到类“COM”:6堆栈跟踪:#0{main}抛出/var/www/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。您需要/包含声明类的文件的位置是什么?
在php.ini中,代码>在一行的开头表示这行是一条注释,duh@哦,我不知道。谢谢。您的服务器运行的是什么操作系统?听起来好像您是在Windows上编写代码,而在Linux上运行代码。如果是这样的话,我认为你不能使用COM对象。谢谢你刚刚更改了,但它没有工作,我的问题可能是服务器本身。OP很困惑<代码>在/var/www/client1/web1/web/nordin/save.php中找不到“COM”类表示Unix环境,但php\u COM\u dotnet.dll
用于Windows@Machavity不,我在windows上,我甚至有文件php\u com\u dotnet.dll