0

テキストファイルのコンテンツを取得したいのですが、使用していますfile_get_contents()

しかし、ファイル名に空白を含むファイルを読み込もうとすると問題が発生します。

例:/home/project/text cv.txtを使用して読み取ることはできませんfile_get_contents()

.txt ファイルを読み取る代替手段はありますか?

4

3 に答える 3

3

ドキュメントにはヒントがあります。 If you're opening a URI with special characters, such as spaces, you need to encode the URI with urlencode().

于 2012-07-04T06:52:16.147 に答える
2

別のオプションは、realpath() を使用して URI をファイルにラップすることです。

$path = realpath( dirname(__FILE__).'/../_files/file with space.txt' );
$data = file_get_contents($path);
于 2012-07-04T07:10:54.283 に答える
-1

試してみるfile_get_contents(text cv);file_get_contents(text%20cv);

于 2012-07-04T06:53:11.853 に答える