PHP 和cli 有什麼關係 ,運行一個PHP檔案 報錯
這是報錯資訊 This example script is written to run under the command line ('cli') version of the PHP interpreter, but you're using the 'apache2handler' version
下面是我啟動並執行php 檔案 內容
if (php_sapi_name() != "cli") { //應該是這句話 是不是要配置某個選項 支援 cli啊
print "This example script is written to run under the command line ('cli') version of\n";
print "the PHP interpreter, but you're using the '".php_sapi_name()."' version\n";
exit(1);
}
try {
// Open the database for update, creating a new database if necessary.
$database = new XapianWritableDatabase($argv[1], Xapian::DB_CREATE_OR_OPEN);
$indexer = new XapianTermGenerator();
$stemmer = new XapianStem("english");
$indexer->set_stemmer($stemmer);
$para = '';
$lines = file("php://stdin");
foreach ($lines as $line) {
$line = rtrim($line);
if ($line == "" && $para != "") {
// We've reached the end of a paragraph, so index it.
$doc = new XapianDocument();
$doc->set_data($para);
// Set the database handle to Null to ensure that it gets closed
// down cleanly or uncommitted changes may be lost.
$database = Null;
} catch (Exception $e) {
print $e->getMessage() . "\n";
exit(1);
}
?>