Please review the below code and advise what is wrong with it when using require.
First here is the code that works (not using require in it):
<?php
//require("_start.inc");
session_start();
if(!isset($_SESSION['user']))
{
echo "<h1 style='color:red'>Please <a href='../index.php'>login</a> first!</h1>";
}
else
{
?>
<!DOCTYPE html>
<html>
<head>
<title>Main window</title>
</head>
<body>
<h1>Admin panel</h1>
<?php
require("header.inc");
?>
</body>
</html>
<?php
//require("_end.inc");
}
?>
And here is the version that doesn't work, _start.inc and _end.inc are exactly what is written in the above code, but the below one give me an error: Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\admin_start.inc on line 9
<?php
require("_start.inc");
/*session_start();
if(!isset($_SESSION['user']))
{
echo "<h1 style='color:red'>Please <a href='../index.php'>login</a> first!</h1>";
}
else
{
*/
?>
<!DOCTYPE html>
<html>
<head>
<title>Main window</title>
</head>
<body>
<h1>Admin panel</h1>
<?php
require("header.inc");
?>
</body>
</html>
<?php
require("_end.inc");
//}
?>