の内容を取得することは可能ですか?
/etc/asterisk/sip.conf
PHPで印刷しますか?
私はそれを試しています:
<?php
$filecontents = file_get_contents("/etc/asterisk/sip.conf");
print $filecontents;
?>
しかし、それは機能していません... ファイルのchmodは正しいです。
ありがとうございました
上記のディレクトリ パスが正しい場合、これは主に 2 つの主要なアクセス許可に依存します。「/ect」について言及されましたが、コードのタイプミスである可能性があります。
本当に申し訳ありません.. sip.conf ファイルが空でした。
それがあなたの問題かどうか/ect
はわかりませんが、伝統的なディレクトリが/etc
それ以外の場合は、これを の直前に置きますfile_get_contents
:
ini_set("display_errors", 1);
error_reporting(E_ALL);
そして、エラー出力を確認してください
しかし、それは機能していません...私は権利を設定しました。
何が機能していないかによって、間違った権利を設定している可能性があります。
戻り値を検証して、次のことを確認します。
$filecontents = file_get_contents("/ect/asterisk/sip.conf");
if ($filecontents === FALSE)
{
echo "I made an error.\n";
}
else
{
print $filecontents;
}
最も可能性の高い問題はect
、どのバリアントがetc
存在する可能性が高いかということです。ファイルが存在するかどうかを確認するには、ファイルをテストします。完全なコード:
$file = "/ect/asterisk/sip.conf";
if (!is_file) {
echo "The file $file does not exists. Please check the path.\n";
}
if (!is_readable) {
echo "The file $file is not readable. Ensure you can read it.\n";
}
$filecontents = file_get_contents($file);
if ($filecontents === FALSE)
{
echo "I made an error.\n";
}
else
{
print $filecontents;
}