I want to use Prolog with PHP. Is it possible?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
There are always the exec-familiy functions to execute/spawn another process.
Most Prologs allow for prolog code to be compiled into a binary. You could try calling this binary from within PHP using some kind of process call as already mentioned.
I wrote a translator that can convert some simple PHP programs into Prolog and vice-versa.
This is a possible input program:
...and this is the output program:
This translator is only a proof-of-concept, but it may still make it easier to convert some simple PHP programs into Prolog.
As suggested above, you can execute a Prolog interpreter or binary. However, most Prolog implementations also export a C API that can be used to call the Prolog interpreter.
You could create a small PHP module to start an interpreter and execute queries. For instance, the SICStus documentation describes using Prolog from C in detail: