Jump to content

Need help/info using "include"


xwishmasterx

Recommended Posts

Hello

 

I am getting some errors when trying to build up a page using include ( Parse error: syntax error, unexpected $end in..)

 

I know why and where this is happening, but not why it won't work (pretty sure I've done it in the past), anyway more details:

My page is a simple build

 

include header.php

page stuff

include footer.php

 

 

The problem is the header checks if the user is logged in and such and ends with:

if($_SESSION['loggedin'] != TRUE) {
header("Location: /index.php?=loggedout");
}else{
?>

 

Now the last "else" statement isn't closed which gives the error, but why can't I close it in the footer? like so:

 

<?php
}
?>

 

Any info would be appreciated ;)

Edited by xwishmasterx
Link to comment
Share on other sites

You cannot split the syntax for any one statement between files. Any language statement that you open, must be closed in the same file.

 

The main file is parsed, tokenized, and interpreted when the page is requested. Any induced code is parsed, tokenized, and interpreted when the include statement is executed.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.