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

ステップアップしていくブログです。
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
注意: 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
$_SERVER['REMOTE_ADDR']
$_SERVER['HTTP_X_FORWARDED_FOR']
int x = 1; x = "こんにちは";はコンパイルエラーが出ます。しかしPHPは、
$x = 1 $x = array(1,2,3)でもエラーが出ません。
function f($x)
{
if (is_array($x)) {
// 配列用の処理
} else {
// 配列以外の処理
}
}
function f(array $x)
{
// 配列の処理
}
"require-dev": {
"phpunit/phpunit": "4.3.*",
"phpunit/dbunit": ">=1.2",
"mockery/mockery": "dev-master@dev"
},
こちらを追加しましょう。mockeryはモックのライブラリです。
$ composer updateこれで上記のライブラリがインストールされます。
$ phpunit --version PHPUnit 4.3.4 by Sebastian Bergmann.Laravelでは、テストをapp/tests以下に置きます。