ありがとうございます。エラーメッセージを与える.phpファイルから文字セットを取得するPHPコード
警告:コードの下に使用している場合
この警告を取得するのfile_get_contents(test.phpを)を[取得function.file--内容]:中/パス/インデックスそのようなファイルまたはディレクトリ:ストリームをオープンに失敗しました。 php on line so-n-so。
は、ここで私が使用していたコードだ、
<?php
// Scan directory for files
$dir = "path/";
$files = scandir($dir);
// Iterate through the list of files
foreach($files as $file)
{
// Determine info about the file
$parts = pathinfo($file);
// If the file extension == php
if ($parts['extension'] === "php")
{
// Read the contents of the file
$contents = file_get_contents($file);
// Find first occurrence of opening template tag
$from = strpos($contents, "{{{{{");
// Find first occurrence of ending template tag
$to = strpos($contents,"}}}}}");
// Pull out the unique name from between the template tags
$uniqueName = substr($contents, $from+5, $to);
// Print out the unique name
echo $uniqueName ."<br/>";
}
}
?>
はい、それはファイルを見つけることです。しかし、 'file_get_contents'はそのパスを知らなくてもそれを読み取ることができません。そして、あなたのコードは現在、 '' file.php "'必要な '' path/file.php "'をfile_get_contentsに渡します。したがって、エラーメッセージ。 – mario
ありがとうございました! – KGDD