这是报错信息 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);
}include "xapian.php";if ($argc != 2) {
print "Usage: {$argv[0]} PATH_TO_DATABASE\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); $indexer->set_document($doc);
$indexer->index_text($para); // Add the document to the database.
$database->add_document($doc); $para = "";
} else {
if ($para != "") {
$para .= " ";
}
$para .= $line;
}
} // 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);
}
?>
下面是我运行的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);
}include "xapian.php";if ($argc != 2) {
print "Usage: {$argv[0]} PATH_TO_DATABASE\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); $indexer->set_document($doc);
$indexer->index_text($para); // Add the document to the database.
$database->add_document($doc); $para = "";
} else {
if ($para != "") {
$para .= " ";
}
$para .= $line;
}
} // 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);
}
?>
解决方案 »
- php 怎么定义函数的别名 和类的别名的?
- 如题
- 如何判断用户上传了文件?
- 用PHP如何读取int(10)字段
- 如果使用preg_replace 函数中得正则表达式,我弄了一下午弄不出来,救命了大家。
- 怎么实现以下2个功能,有源代码的贡献出来.可以吗???
- 问大家,mysql 的sql语句:select * field like '%大%',查出所有的??怎么回事??问大家,mysql 的sql语句:select * field like '%大
- 为什么我的cookie总是慢半拍??
- 請大家幫忙看看!!!能用 <select> 做出分層的下拉菜單不,如果不行有什麼辦法來代替呢???
- 怎么读取sql某个表单把字段网格显示在页面上?
- Warning: mysql_fetch_row() expects parameter 1 to be resource
- 这样的二维数组怎么构造?
用命令行工具运行它 linux命令行,或win的cmd都可以
CLI 是命令行模式,例如在winXP 的命令行窗口cmd 里边,php my_script.php 使用php.exe 直接运行php代码,相当于控制台应用。
不是web服务器上运行的。
真需要的话,改成 web服务器上运行的版本就可以。$argv[0] 是从命令行获取的参数,改成用变量设置或$_GET或$_POST 获得