Jump to content

Recommended Posts

Hi. I'm tidying up some of my scripts.

 

Is it possible to include a php file with unclosed brackets?

 

I went ahead and created two files. header.php and footer.php because my scripts began and ended the same way.

 

header.php

<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/mysql_connect.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/config.inc.php'); 
require_once($_SERVER['DOCUMENT_ROOT'].'/fckeditor/fckeditor.php'); 
require_once($_SERVER['DOCUMENT_ROOT'].'/ref.php'); 

session_start();
if(isset($_SESSION['name']))
{
?>

 

footer.php

<?php
include("console.inc.php");
}
else
{
header("Location:/admin/login.php?ref=12"); 
}
?>

 

As you can see the files individually have unbalanced braces. But when they combine at the top and bottom of my script they balance out.

 

Are these includes possible?

 

 

No this is not possible. You're better of just doing

 

<?php
session_start();
if(!isset($_SESSION['name']))
{
    header("Location:/admin/login.php?ref=12"); 
    exit;
}

require_once($_SERVER['DOCUMENT_ROOT'].'/mysql_connect.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/config.inc.php'); 
require_once($_SERVER['DOCUMENT_ROOT'].'/fckeditor/fckeditor.php'); 
require_once($_SERVER['DOCUMENT_ROOT'].'/ref.php'); 
?>

I could imagine if you include all the files into one file in correct order it would work. Because isn't include same as the code was written in the file in the spot where the include happens. But I don't think this will be a good way to do anything.

I could imagine if you include all the files into one file in correct order it would work. Because isn't include same as the code was written in the file in the spot where the include happens. But I don't think this will be a good way to do anything.

It wont work as PHP will first evaluates the code. If there are syntax errors it be able to parse the code.

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.