Friday, July 31, 2015

Invoking SWI prolog from PHP

Php File invoking Swi Prolog by passing an argument


php file (index.php)

<?php 
$arg = 'Parameter';
        $cmd = 'C:\progra~1\swipl\bin\swipl.exe C:\xampp\htdocs\prolog\test.pl '.$arg;
        $output = exec($cmd);
        echo $output;
 ?>

swi prolog file (test.pl)

:- initialization main.

main :-
  current_prolog_flag(argv, Argv),
  format('Testing Prolog File. Argument is: ~w\n', Argv),  halt(0).