システムを作っているときにページごとで


出力だけは文字コードを違くしたいときが


たまにある。


簡単な方法が紹介されていたのでメモひらめき電球


文字コードを変えて一気に出力する方法(PHPのob_start) | IDEA*IDEA

以下引用です。

<?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");
?>