ユーザ用ツール

サイト用ツール


サイドバー


メニュー




スポンサーリンク





php:関数使用例:ファイルシステム:fputs

PHP:関数使用例:ファイルシステム:fputs

分類

ファイルシステム

機能

バイナリセーフなファイル書き込み処理(fwrite() のエイリアス)

sample

ソース

<?php
$file_name ="/home/hoge/public_html/test/test.txt";
$write_data= "Hellow php";
 
$file = fopen($file_name,"r+") or die("File Open Error");
set_file_buffer($file,0);
flock($file, LOCK_EX);
fputs($file,$write_data);
flock($file, LOCK_UN);
rewind($file);
$read_data = fgets($file);
echo $read_data;
?>
<html>
<head>
<title>t_file_exist.php</title>
<body>
<input type="hidden" name="read_data" value="<?php print $read_no; ?>">
</body>
</html>

出力結果

Hellow php 
php/関数使用例/ファイルシステム/fputs.txt · 最終更新: 2015/12/08 02:08 by dokuroot