- 2025/11/17
- Category :
[PR]
×
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

ステップアップしていくブログです。
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
$ php artisan migrate:rollback
注意: readfile() 自体にはメモリに関する問題はなく、 巨大なファイルを送ってもかまいません。out of memoryエラーが出る場合は、 ob_get_level() で出力バッファリングを無効にしてください。
返り値 ¶ 出力バッファリングハンドラのネストレベルを返します。 バッファリングがアクティブでない場合はゼロを返します。
while (ob_get_clean()) {
ob_end_clean();
}
<?php
exec('ls .', $output);
foreach ($output as $file) {
exec('wc -m '.$file, $wc);
echo ($wc[0]."\n");
}
exec('ls .', $output);
$ php wc.php 8 a.txt 8 a.txt 8 a.txt 8 a.txt
<?php
exec('ls .', $output);
foreach ($output as $file) {
exec('wc -m '.$file, $wc);
echo ($file.':'.$wc[0]."\n");
}
$ php wc.php a.txt:8 a.txt b.txt:8 a.txt c.txt:8 a.txt wc.php:8 a.txt
<?php
exec('ls .', $output);
foreach ($output as $file) {
exec('wc -m '.$file, $wc);
var_dump($wc);
}
$ php wc.php
array(1) {
[0]=>
string(7) "8 a.txt"
}
array(2) {
[0]=>
string(7) "8 a.txt"
[1]=>
string(8) "12 b.txt"
}
array(3) {
[0]=>
string(7) "8 a.txt"
[1]=>
string(8) "12 b.txt"
[2]=>
string(7) "4 c.txt"
}
array(4) {
[0]=>
string(7) "8 a.txt"
[1]=>
string(8) "12 b.txt"
[2]=>
string(7) "4 c.txt"
[3]=>
string(10) "192 wc.php"
}
配列に既に何らかの要素が 含まれる場合は、exec() は配列の最後に追加されることに注意してください。関数が要素を追加することを望まないのなら、それが exec() に渡される前に、配列の unset() を呼び出してください。
<?php
exec('ls .', $output);
foreach ($output as $file) {
unset($wc);
exec('wc -m '.$file, $wc);
echo ($wc[0]."\n");
}
$ php wc.php 8 a.txt 12 b.txt 4 c.txt 190 wc.php
$ chmod -R 777 .
$ find . -type f | xargs chmod 777
名前
xargs - 標準入力からコマンドラインを作成し、それを実行する
書式
xargs [-0prtx] [-e[eof-str]] [-i[replace-str]] [-l[max-lines]] [-n max-args] [-s max-chars] [-P max-procs] [--null] [--eof[=eof-str]]
[--replace[=replace-str]] [--max-lines[=max-lines]] [--interactive] [--max-chars=max-chars] [--verbose] [--exit] [--max-procs=max-procs] [--max-args=max-
args] [--no-run-if-empty] [--version] [--help] [command [initial-arguments]]
説明
このマニュアルページは GNU 版 xargs に関して記述したものである。 xargs はまず標準入力から空白または改行で区切られた文字列群を読み込む (空白はダブルクォー
テーション・シングルクォーテーション・バックスラッシュによってプロテクトできる)。そして command (デフォルトは /bin/echo) に文字列群を続けたコマンドライン
を実行する。 initial-arguments が指定されていれば、 command と標準入力から渡された文字列の間に、 command への引き数として渡される。標準入力の空行は無視さ
れる。
$ find . -type d
File::append('./abc.txt', 'hello!');
File::move('./abc.txt', './new_abc.txt');
File::copy('./abc.txt', './new_abc.txt');
File::extension('./abc.txt');
拡張子だって、Filesystemなら、ほらこの通り。