PHPの初心者です。目標は「外部ファイルです!」と3回表示されるようなプログラムを組みたいです。
初歩的な質問で申し訳ないのですが、ググってもよくわからないのでお助け願います。
3-19-1.php
<?php
for($i=1;$i<=3;$i++){
echo "外部ファイルです!<br>";
}
?>
3-19-2.php
<html>
<head>
<meta http-equiv="Content-type"
content="text/html; charset=Shift_Jis">
<title>●:外部ファイルの取り込み・利用
(require,include)</title>
</head>
<body>
<?php
//----------------------------------------------
//■ requireを使う
//----------------------------------------------
echo "<b>require</b><br>";
require "3-19-1.php";
//----------------------------------------------
//■ includeを使う
//----------------------------------------------
echo "<b>include</b><br>";
include "3-19-1.php";
?>
</body>
</html>
表示結果
require
�O���t�@�C�������I
�O���t�@�C�������I
�O���t�@�C�������I
include
�O���t�@�C�������I
�O���t�@�C�������I
�O���t�@�C�������I
(PHP)ファイルの取り込みで文字化けになる問題について
Re: (PHP)ファイルの取り込みで文字化けになる問題について
外部ファイルの文字コードがShift-JISではないからでは?