SIema. Mam problem następujący: przypuśćmy w pliku header.php chcę dodać znacznik php <?php echo'test'; ?> niby dobrze, ale strona wczytuje go jako komentarz html <!--<?php echo'test'; ?>-->
Kilka fragmentów kodu odpowiednich za wczytywanie plików: między innym index.php. Używam file_get_content, próbowałem też require.
INDEX.PHP:
<?php
session_start();
header('Content-Type: text/html; charset=utf-8');
function __autoload($class)
{
$filename = 'class/'.$class.'.php';
require($filename);
}
if(isset($_GET["site"]))
$activeSite = $_GET["site"];
if(!file_get_contents("header.php"))
echo "Brak pliku header.php";
else echo file_get_contents("header.php");
if(!file_get_contents("main.php"))
echo "Brak pliku main.php";
else if(!isset($activeSite))
echo file_get_contents("main.php");
if(isset($activeSite) && (!file_get_contents($activeSite)))
echo "Brak pliku ".$activeSite;
else echo file_get_contents($activeSite);
if(!file_get_contents("footer.php"))
echo "Brak pliku footer.php";
else echo file_get_contents("footer.php");
if(isset($_POST['StartReg']))
{
$newuser = new user(Array("localhost","root","","rowery"));
echo $newuser->Register(Array($_POST['Login'], $_POST['Password'],$_POST['Email'],$_POST['UserPhone']));
}
?>
Dobra teraz fragment header.php
<ol>
<li><a href="?site=login.php">Logowanie</a></li>
<li><a href="?site=register.php">Dołącz</a></li>
NP: <?php echo'<li>test</li>'; ?> <!--TO będzie jako komentarz -->
</ol>