windows 致命错误:找不到类“COM”PHP。Win7 - Apache - PHP

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12781145/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 15:55:55  来源:igfitidea点击:

Fatal error: Class 'COM' not found PHP. Win7 - Apache - PHP

phpwindowscom

提问by e-Learner

$myapp = new COM("word.application");
// returns a fatal error: "Class 'COM' not found in c:/www/comConnector.php"

shell_exec("whoami");
//returns "NT authority/system"

My system setup

我的系统设置

  • Win7 Pro
  • Apache Server version: Apache/2.2.23 (Win32)
  • PHP

    PHP 5.3.16 (cli) (built: Aug 15 2012 20:06:57)
    Copyright (c) 1997-2012 The PHP Group
    Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

  • Win7专业版
  • Apache 服务器版本:Apache/2.2.23 (Win32)
  • PHP

    PHP 5.3.16 (cli)(构建时间:2012 年 8 月 15 日 20:06:57)
    版权所有 (c) 1997-2012 PHP Group
    Zend Engine v2.3.0,版权所有 (c) 1998-2012 Zend Technologies

回答by Radu Bompa

Add COM support in php.ini:

在 php.ini 中添加 COM 支持:

 [COM_DOT_NET]
     extension=php_com_dotnet.dll

回答by Mehran

Since you are using PHP 5.3.16, make sure that you are pointing to the global namespace:

由于您使用的是 PHP 5.3.16,请确保您指向全局命名空间:

$myapp = new \COM("word.application");

Even though your PHP file might be in global namespace already, but it's a good practice.

即使您的 PHP 文件可能已经在全局命名空间中,但这是一个很好的做法。