0

i have a site made using PHP and backend mysql. There is a prolog file (.pro extension) which I would like to integrate with this site.

My prolog source file can be queried like this -

myprolog(Input, Output).

So I give prolog Input, and it returns its result by binding it to Output.

I am expecting one of my php pages, says callprolog.php to query this prolog source file by passing the Input, and then store the result from Ouput into a php variable for further processing.

Implementations - PHP 5, MySQL, SWI Prolog.

Please let me know how to establish this connection betwen the php file and prolog source, pass/get data to/from prolog/php file.

Thank you!

4

1 回答 1

2

我已经完成了一些需要在 php 和 prolog(.pl) 文件之间建立连接的项目。我就是这样做的:我使用了这样的 php exec函数:

exec(prolog_path -f $your_file_name.pro  -g your_predicate/query_goes_here)

上面这行代码的作用是定义你的 prolog bin 文件所在的位置,告诉 prolog 需要查阅的文件的名称,然后输入所需的查询。因此,在您的情况下,上面的代码行将如下所示:

exec("\"c:/program files/swipl/bin/swipl.exe\"" -f your_prolog_filename.pro -g myprolog(Input,Output))

您可能需要更改序言路径,但这就是我实现 php-prolog 连接的方式。请阅读我提供给您的链接中的 exec 函数是如何工作的。

于 2012-10-20T08:22:42.003 回答