実装 $result = '改行' . "\n" . $変数 . "\n" . $変数 . "\n" . echo $変数; echo $result; 参考 PHPで出力した文字列をjavascriptのalertで表示したら改行されないです。 環境 php 関連