I am trying to make a sudoku game with PHP and prolog, the idea is to use prolog program to solve the sudoku then get the results via PHP, I have write this code down but I'm getting a empty output
I have even try to use var_dump
to test and i'm getting string '' (length=0)
here is my code:
<!DOCTYPE>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Soduku</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="content">
<?php
$output=exec("\"c:/Program Files (x86)/swipl/bin/swipl-win.exe\" -g \"test,halt\" -t \"halt(1)\" test.pl ");
var_dump($output);
echo $output;
echo"<pre>";
print_r($output);
echo"</pre>";
?>
</div>
</body>
</html>
my code after edition
<!DOCTYPE>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Soduku</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="content">
<?php
exec('"c:\\Program Files (x86)\\swipl\\bin\\swipl-win.exe" -g "st,halt" -t "halt(1)" -s test.pl',$output,$return_var);
var_dump($output);
echo $return_var;
?>
</div>
</body>
</html>
it display this result
array (size=0)
empty
0
The doc says that
exec
returns the last line and you probably have an empty line as a last line. To get the full output, use the second parameter like this: