<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>PHP</title>
</head>
<body>
<?php
// 1.echoで文字列を表示する
$data= 'Hello';
echo $data, '<br />';
// 2.文字列をテキストファイルに保存する
$file = fopen("sample.txt", "w");
flock($file, LOCK_EX);
fwrite($file, $data . "\n");
flock($file, LOCK_UN);
fclose($file);
// 3. 2 で保存したテキストファイルを読み込んで表示させる
$file = fopen("sample.txt", "r");
flock($file, LOCK_EX);
echo fgets($file), '<br />';
flock($file, LOCK_UN);
fclose($file);
?>
<form method = "GET" action = "get_1.php">
<label for = "txt">文字列データ:</label>
<input id = "txt" type = "text" name = "txt" size = "15" />
<input type = "submit" value = "送信" />
</form>
</body>
</html>