現在の言語: 日本語 |
file_put_contents |
出力関連 |
| 第1引数(必須) | ファイル名 | 書き込み先のパス | |
| 第2引数(必須) | 文字列、配列、またはストリームリソース | 書き込みデータ | |
| 第3引数(任意) | フラグ | [FILE_APPEND] 既存の内容を消さずに、追記します。 [LOCK_EX] 書き込み中にファイルを排他ロックし、他のプロセスからの干渉を防ぎます。 [FILE_USE_INCLUDE_PATH] include_path(ライブラリなどが置いてある標準ディレクトリ群)の中から、 指定したファイル名を探して書き込みを試みます。 ※ |(パイプ)記号を使うことで、複数の設定を同時に適用できます。 |
[ケース1]
$d1=(int)$data["d1"];
$d2=(int)$data["d2"];
$lang=(int)$data["lang"];
file_put_contents('debug.log', "d1:$d1 d2:$d2 lang:$lang\n", FILE_APPEND);
[出力例]
d1:$7 d2:$2 lang:0
[ケース2]
[localhost/index.php]
equire_once("clsMain.php");
class index extends oya
{
function test()
{
file_put_contents('debug.log', "index.php test()\n", FILE_APPEND);
}
}
[localhost/common/index.php]
class oya
{
function test2()
{
file_put_contents('debug.log', "oya.php test2()\n", FILE_APPEND);
}
}
$cls = new index();
$cls->test();
$cls->test2();
[ケース3]
[localhost/index.php]
equire_once("clsMain.php");
class index extends oya
{
function test()
{
file_put_contents(__DIR__ . 'debug.log', "index.php test()\n", FILE_APPEND);
}
}
[localhost/common/index.php]
class oya
{
function test2()
{
file_put_contents(__DIR__ . 'debug.log', "oya.php test2()\n", FILE_APPEND);
}
}
$cls = new index();
$cls->test();
$cls->test2();
[Case 1]
$d1=(int)$data["d1"];
$d2=(int)$data["d2"];
$lang=(int)$data["lang"];
file_put_contents('debug.log', "d1:$d1 d2:$d2 lang:$lang\n", FILE_APPEND);
[Output example]
d1:$7 d2:$2 lang:0
[Case 2]
[localhost/index.php]
equire_once("clsMain.php");
class index extends oya
{
function test()
{
file_put_contents('debug.log', "index.php test()\n", FILE_APPEND);
}
}
[localhost/common/index.php]
class oya
{
function test2()
{
file_put_contents('debug.log', "oya.php test2()\n", FILE_APPEND);
}
}
$cls = new index();
$cls->test();
$cls->test2();
[Case 3]
[localhost/index.php]
equire_once("clsMain.php");
class index extends oya
{
function test()
{
file_put_contents(__DIR__ . 'debug.log', "index.php test()\n", FILE_APPEND);
}
}
[localhost/common/index.php]
class oya
{
function test2()
{
file_put_contents(__DIR__ . 'debug.log', "oya.php test2()\n", FILE_APPEND);
}
}
$cls = new index();
$cls->test();
$cls->test2();
| 著作権情報 |
| ホームページおよびアプリ等に掲載されている情報等については、いかなる保障もいたしません。 ホームページおよびアプリ等を通じて入手したいかなる情報も複製、販売、出版または使用させたり、 または公開したりすることはできません。 当方は、ホームページおよびアプリ等を利用したいかなる理由によっての障害等が発生しても、 その結果ホームページおよびアプリ等を利用された本人または他の第三者が被った損害について 一切の責任を負わないものとします。 |