doulin9679 2015-11-07 07:42
浏览 50

exec()与php命令不返回任何值

What actually i want to do is to get contents from the winword file in my web page. for this purpose i used the exec() method, i also tried the following code:

$pCom = new COM("WScript.Shell");
$pShell = $pCom->exec("Notepad.exe");
$sStdOut = $pShell->StdOut->ReadAll;    # Standard output
$sStdErr = $pShell->StdErr->ReadAll;    # Error
echo($sStdOut);

the above code through an Exception that:

 Fatal error: Class 'COM' not found in D:\xampp\htdocs\test\tests\Notepad.php on line 9

I have no idea what to do and how to do this?

  • 写回答

1条回答 默认 最新

  • dshxbrzgi090608692 2015-11-07 07:49
    关注

    You have two issues with your approach:

    1. a text editor does not output text written in it when closing the editor. So why would you expect to receive the text when firing the editor by means of an exec() call?

    2. you miss understood how the exec() command actually works, I assume you did not really read the documentation of the exec() function which clearly states that the return value of an executed command is the last line of its output. That is not what you want.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题