1

I'm trying to incorporate ProLog to a PHP project that I have to do for a class in the university. The thing is that I was searching in Internet a library or a command to execute with the 'exec()' method in PHP, I could call a method with no parameters from ProLog to PHP, one that just write "Hello World", that's OK, but when I try to call a method that receive a parameter, for example 'test(X).' that returns a list or a string, the command doesn't work. This is my command:

swipl -f testing.pl -g test(X),halt

When I run the command in a terminal by myself to check what it returns I found it returns an error:

bash: syntax error near unexpected token `('

I don't know why it's happening and I did researched a lot in here and other websites, couldn't find nothing. I would appreciate the help.

My final goal is to execute a command from PHP to Prolog that returns a list so I can work with the list in my PHP project.

(I'm using Ubuntu 16.04 LTS, just in case.)

-My testing.pl file:

test1:-write('Hello World')

test([testing,list])
3
  • 2
    just surround with double quotes... assuming in testing.pl there are the clause terminating dots. Like -g "test(X),halt"
    – CapelliC
    Jun 28, 2016 at 5:04
  • 1
    I second this. See for example also: $ echo hello(X), which leads to: bash: syntax error near unexpected token (, whereas $ echo "hello(X)" works as expected.
    – mat
    Jun 28, 2016 at 7:43
  • Single quotes are even better if you do not need $-interpolation
    – false
    Jun 28, 2016 at 11:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.