LoginSignup
0
0

More than 1 year has passed since last update.

MAMPでPHP文字化け

Last updated at Posted at 2022-11-23

MacでMAMPインストールしたが文字化けしたので、対策を備忘録
PHP7.4.12のバージョンを使用

参考にした記事
https://plaza.rakuten.co.jp/taro3chidayo/diary/202005090000/
https://qiita.com/redamoon/items/28e7bbe1ccbf58cbbd04

MAMP/bin/php/php7.4.12/conf/php.ini
php.iniを一部書き換える
その前にバックアップとっておく

左辺をワード検索して、右辺を書き換え
文頭に「;」があれば削除
default_charset = UTF-8
date.timezone=Asia/Tokyo
mbstring.language = Japanese
mbstring.http_input = auto
mbstring.internal_encoding = UTF-8
mbstring.detect_order = UTF-8,SJIS,EUR-JP,JIS,ASCII

これでMANPを再起動すれば治るはずが、治らない。

次に参考にした記事
https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q10118376545

自分が格納したhtmlファイルを確認する。
エディタ上で文字コードをUTF=8に指定しているが、ファイル上では宣言していない。

以下の内容でアップしてみる

<html lang="ja">
<head>
    <meta charset="UTF-8">
    <form method="GET" action="example.php">
        お名前<input type="text" name="username">
        <input type="submit" value="送信">
    </form>
</head>
<body>
</body>
</html>

無事文字化けが治りましたとさ。おわり。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0