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);
}
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);
}
?>
------解决方案--------------------
command-line interface 命令行界面
用命令行工具运行它 linux命令行,或win的cmd都可以
------解决方案--------------------
類似於shell吧..就是命令行工具了,環境變量什麼的當然就不一樣了。如果你的腳本是web的那就不要在cli下調試,否則多數可能都會出錯。其他的不是很瞭解,cli基本沒有這麼在下面跑過東西
------解决方案--------------------
意思是说,你的这段代码是设计运行在CLI模式下的,但是你现在用的是apache web服务器, 所以这段代码不能运行.
CLI 是命令行模式,例如在winXP 的命令行窗口cmd 里边,php my_script.php 使用php.exe 直接运行php代码,相当于控制台应用。
不是web服务器上运行的。
真需要的话,改成 web服务器上运行的版本就可以。$argv[0] 是从命令行获取的参数,改成用变量设置或$_GET或$_POST 获得

thesecrettokeepingaphp-poweredwebsterunningsmootlyunderheavyloadinvolvesseveralkeystrategies:1)emform opcodecoduceSciptionexecutiontime、2)aatabasequerycachingwithiThing withiThistolessendavasoload、

コードをより明確かつ維持しやすくするため、依存関係が関心(DI)に注意する必要があります。 1)DIは、クラスを切り離すことにより、よりモジュール化されます。2)テストとコードの柔軟性の利便性を向上させ、3)DIコンテナを使用して複雑な依存関係を管理しますが、パフォーマンスの影響と円形の依存関係に注意してください。

はい、最適化されたAphPossibleandessention.1)CachingingusapCutoredatedAtabaseload.2)最適化、効率的なQueries、およびConnectionPooling.3)EnhcodeCodewithBultinctions、Avoididingglobalbariables、およびUsingopcodeching

keyStrategIestsoSificlyvoostphpappliceperformanceare:1)useopcodecachinglikeToreexecutiontime、2)最適化abaseの相互作用とプロペラインデックス、3)3)構成

aphpDependencyInjectionContaineriSATOULTAINATINAGECLASSDEPTINCIES、強化測定性、テスト可能性、および維持可能性。

SELECT DEPENTENCINGINOFCENT(DI)大規模なアプリケーションの場合、ServicElocatorは小さなプロジェクトまたはプロトタイプに適しています。 1)DIは、コンストラクターインジェクションを通じてコードのテスト可能性とモジュール性を改善します。 2)ServiceLocatorは、センター登録を通じてサービスを取得します。これは便利ですが、コードカップリングの増加につながる可能性があります。

phpapplicationscanbeoptimizedforspeedandEfficiencyby:1)enabingopcacheinphp.ini、2)PreparedStatementswithpordatabasequeriesを使用して、3)LoopswithArray_filterandarray_mapfordataprocessing、4)の構成ngincasaSearverseproxy、5)

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

AtomエディタMac版ダウンロード
最も人気のあるオープンソースエディター

メモ帳++7.3.1
使いやすく無料のコードエディター

SAP NetWeaver Server Adapter for Eclipse
Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

PhpStorm Mac バージョン
最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール
