Jump to content

loading php at bottom of the page and echo at top?


acctman

Recommended Posts

i need to include a php at the bottom of my template but I need for the output to appear in the middle of that page. The reason for this is because the include file uses Global variables that affect any sql coding that is loaded after it.

this is what i've been trying but no luck

 

middle of page

<?php foo(); ?>

 

bottom of page

<?php 
function foo() {
include('forums/newest_posts.php'); 
}
?> 

Link to comment
Share on other sites

Have you tried ob_start, ob_get_contents and ob_flush?

 

no luck i tried this code

 

middle of page

<?php echo $string; ?> 

 

bottom

<?php
$string = get_include_contents('forums/newest_posts.php');
function get_include_contents($filename) {
    if (is_file($filename)) {
        ob_start();
        include $filename;
        $contents = ob_get_contents();
        ob_end_clean();
        return $contents;
    }
    return false;
}


?>

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.