从 php 调用 swi-prolog [英] invoking swi-prolog from php
问题描述
我正在尝试从 php 脚本中调用 swi-prolog,例如:
I am trying to invoke swi-prolog from within a php script like :
exec("start plwin.exe -f C:\\path\\load.pl -g run_from_file.", $os1);
print_r($os1);
我可以看到 prolog 窗口被打开并编译文件,但立即退出,显示退出状态为 1.我确定它没有执行我想要执行的谓词.
I can see that prolog window gets opened and complies the file, but immediately exits displaying an exit status as 1. I am sure that it is not executing the predicate I want to to execute.
是否还有其他方法可以使用适当的参数调用 prolog 并保持窗口 open
而不自动退出?
Is there any other to invoke prolog with appropriate parameters and keep the window open
without automatically exiting?
更新:我将系统环境变量配置为安装 prolog 的路径.
UPDATE : I configured the system env variables to the path where prolog is installed.
推荐答案
我也使用了 http://www.j-paine.org/dobbs/prolog_from_php.html ,它给了我一个空白屏幕.要在使用 swipl 的服务器上运行 prolog 文件,我改为:
I have also used the tutorial from http://www.j-paine.org/dobbs/prolog_from_php.html , and it was giving me a blank screen. To run prolog file on a server where swipl is used, I changed to:
$cmd = swipl -f /path/to/myfile.pl -g test,halt -t 'halt(1)';
我在这里找到了所有需要的信息:http://www.swi-prolog.org/pldoc/man?section=cmdline,第 2.4.4 节
I found all needed information here: http://www.swi-prolog.org/pldoc/man?section=cmdline , in section 2.4.4
php 文件的其余部分与示例中相同,现在它真正从 myfile.pl 执行测试.
The rest of the php file is the same as in the example, and now it really executes test from myfile.pl.
也许他可以帮助某人.
这篇关于从 php 调用 swi-prolog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!