<?php
header('Content-Type: text/html; charset=Shift_JIS');
ob_start();
?>
ここにShift-JISで出力したい内容をUTF-8で記述。
<?php
$output = ob_get_contents();
ob_end_clean();
echo mb_convert_encoding($output, 'SJIS', 'UTF-8');
?>
<?php
$file = 'count.txt';
if (!file_exists($file)) {
if (!@touch($file)) {
exit('Cannot create data file!');
}
}
$fh = @fopen($file, 'r+');
if (!$fh) {
exit('Cannot open data file!');
}
flock($fh, LOCK_EX);
$count = (int)fgets($fh);
$count++;
rewind($fh);
if (isset($newcount)) {
$count = $newcount;
}
// うまくいかないことがある? そんときゃ0で
ftruncate($fh, fwrite($fh, $count));
flock($fh, LOCK_UN);
fclose($fh);
echo $count;
?>