问题
I 'd like to pose a question. I tried to connect php with SWI-Prolog using the exec function and my effort was succeful. I have managed to query prolog via php and I was able to echo Prolog's answer.
What I want to do but can't figure how to accomplish it, is to echo the true/false prolog returns.
Lets assume I have a simple knowledge_base.pl file with these facts and rules:
girl(erin).
boy(john).
likes(erin,reading).
likes(john,reading).
hangs_out_with(erin,X) :- likes(X,reading), boy(X), writeln('Someone s got a new friend!!').
Given the simple knowledge base above one can pose queries and prolog respond.
for example:
?- girl(erin). Prolog based on our knowledge base will respond true.
?- girl(john). Prolog based on our knowledge base will respond false.
?- hangs_out_with(erin,john). Proslog will respond : Someone s got a new friend!! true.
What I need is for PHP to echo the true or false respond. How can I achieve that?
Thanks in advance for you help.
来源:https://stackoverflow.com/questions/12428012/how-to-echo-the-true-false-value-prolog-returns-after-a-query