如何在Windows上集成PHP和R?
发布时间:2020-12-14 02:50:40 所属栏目:Windows 来源:网络整理
导读:有一些问题集成 PHP和R.我在这篇文章中工作: http://www.r-bloggers.com/integrating-php-and-r/ 已安装R并使用我们的R脚本验证: Rscript C:inetpubwwwrootclientincludesdecisionTreePredictor.R 20 10 O 1000 10000 5000 0.2 10.2 打印由其计算结果
有一些问题集成
PHP和R.我在这篇文章中工作:
http://www.r-bloggers.com/integrating-php-and-r/ 已安装R并使用我们的R脚本验证: Rscript C:inetpubwwwrootclientincludesdecisionTreePredictor.R 20 10 O 1000 10000 5000 0.2 10.2 打印由其计算结果的单个值: [1] "0" (Rscript.exe的路径在Windows环境变量中设置) 我有一个使用exec()的PHP脚本,它使用以下命令成功测试: $result = exec('dir',$output,$returnVar); echo "<br>result ". print_r($result,true); echo "<br>output <pre>". print_r($output,true),"</pre>"; echo "<br>return ". print_r($returnVar,true); 返回: result 2 Dir(s) 117,749,354,496 bytes free output Array ( [0] => Volume in drive C is C_DRIVE [1] => Volume Serial Number is 7EB2-A074 [2] => [3] => Directory of C:inetpubwwwrootclienttemp [4] => [5] => 05/17/2014 10:29 PM . [6] => 05/17/2014 10:29 PM .. [7] => 05/16/2014 09:24 AM 5,181 dbimporttest.php [8] => 05/17/2014 10:29 PM 0 routput.txt [9] => 05/17/2014 11:42 PM 701 rscripttest.php [10] => 05/16/2014 04:59 PM 425 whoami.php [11] => 4 File(s) 6,307 bytes [12] => 2 Dir(s) 117,496 bytes free ) return 0 当我尝试在exec命令中运行R脚本时,它失败: $result = exec('Rscript.exe C:inetpubwwwrootclientincludesdecisionTreePredictor.R 20 10 O 1000 10000 5000 0.2 10.2',true); 返回: result output Array ( ) return 1 我在跑步: > Windows Server 8 R2 解决方法
无法让exec()工作或输出可用的错误,我决定寻求替代路线.使用COM类似乎给了我正在寻找的东西.
这是最终的操作代码: $command = 'C:Program FilesRR-3.1.0binRscript.exe C:inetpubwwwrootclientincludesdecisionTreePredictor.R 20 10 O 1000 10000 5000 0.2 10.2'; $pCom = new COM("WScript.Shell"); $pShell = $pCom->Exec($command); $sStdOut = $pShell->StdOut->ReadAll; # Standard output $sStdErr = $pShell->StdErr->ReadAll; # Error echo "<pre>$sStdOut</pre>"; 奇怪的是,我无法让exec()完成工作,因为这似乎是大多数讨论R / PHP集成的博客的首选方案. 无论如何,我希望这个解决方案可以帮助那些发现自己的人! 附:您将需要确保扩展在php.ini中打开(默认情况下在安装时关闭):extension = php_com_dotnet.dll (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- xaml – Windows 8 App,更改BackButtonStyle的颜色
- wpf – 通过XAML将Window.Content设置为页面?
- windows – 全自动软件部署和更新系统
- 适合Windows的命令行shell
- windows-server-2008 – 为什么捕获的异常会导致IIS甚至整个
- windows-server-2008 – 我应该在Windows 2008 VM上禁用写缓
- Fix: Windows Script Host access is disabled on this mac
- 自定义Windows GINA身份验证
- windows-server-2008 – 在Windows Server 2008上创建证书
- 我的dll代码从一个exe文件中工作,但是无法从Java loadLibra
推荐文章
站长推荐
- 关于Windows的Lua IDE和调试器的建议
- Windows Server 2016系统的Docker容器初体验
- windows – 如何从显示设备名称获取HMONITOR句柄
- 在Windows Server 2008中自动登录
- windows-phone-7 – Windows Phone 7中MessageBo
- windows-8.1 – Windows应用程序确定TextBlock是
- 重新安装Windows后,git stash无法正常工作
- 如何在Windows / Linux / MacOS上的系统启动时运
- windows-server-2008 – 对于ASP.Net应用程序,Wi
- D DLL可以在SAS中运行吗?
热点阅读