PHP virtual

Discussion in 'PHP' started by grutland, May 15, 2009.

  1. #1
    Hi,

    I am trying to set up a generic system on my Apache/PHP system.
    After setting up aliases and using the "virtual" function in PHP I half accomplished what I was trying to achieve.
    I am having troubles with the "header" command however.

    For example...

    global.php
    
    <?php
    session_start();
    header("Cache-control: private);
    ?>
    
    PHP:
    (May not be axactly right as I am trying to remember with out seeing the file, but it is correct in the file)

    index.php
    
    <?php
    virtual("/conf/global.php");
    ?>
    
    PHP:
    This will result in the error "headers already sent".

    However, if I do the following...
    index.php
    
    <?php
    include 'path/to/global.php';
    ?>
    
    PHP:
    It will work.

    Are there any known problems trying to set headers while using the "virtual" function?
     
    grutland, May 15, 2009 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    PoPSiCLe, May 15, 2009 IP
  3. grutland

    grutland Active Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #3
    Ok, I'll look into that when I get back to my work.

    Will it make any changes to my current code or are there any performance issues with using this?
     
    grutland, May 15, 2009 IP
  4. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #4
    Also, this:

    <?php
    session_start();
    header("Cache-control: private);
    ?>

    Needs to be this:

    <?php
    session_start();
    header("Cache-control: private");
    ?>
     
    jestep, May 15, 2009 IP
  5. grutland

    grutland Active Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #5
    I did say in the first post underneath that snippet it may be wrong but is correct in the file, I was typing that in quickly and forgot the last speech mark.
     
    grutland, May 15, 2009 IP
  6. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #6
    As for performance issues, you shouldn't encounter any, unless you are running an extremely high traffic site - but then you'd probably do some other measures anyway. The existing code should not be affected by this, no.
     
    PoPSiCLe, May 15, 2009 IP
  7. grutland

    grutland Active Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #7
    Hmm, I've turned output_buffering on in my php.ini file and tried using ob_start() but still having the same problem with headers being outputted.
    Any ideas?
     
    grutland, May 16, 2009 IP