user3363963
user3363963

Reputation: 21

ob_get_content() output incorrect

I'm experiencing some problems with ob_start function, probably due to the new PHP 5.5

What I'm trying to do is render some PHP from a third file using inside ob_start.

Here the code:

function fetch()
{
    extract($this->a_vars); // Extract the vars to local namespace

    ob_start();                                              

    include (templateClass.php);  // This file is just 'text'
    $s_contents = ob_get_contents();

    ob_end_clean();

    return $s_contents;
}

Basically what I'm doing is extracting some variables in the local namespace that templateClass will use to render/show some pieces of the text, for example:

...

function func1() {
    return true;
}

<?if(isset($var1)):?>
    function func2() {
        return 2;
    }
<?endif;?>

...

But my variable $s_contents has exactly ALL the content of the file including the php code inside which is not being interpreted. What I need is to get all the php blocks interpreted and the output will be my final usable PHP class.

Any idea?

Upvotes: 1

Views: 473

Answers (1)

user2462948
user2462948

Reputation: 99

  1. include (templateClass.php);
    I hope you have putted quotes in it. Like include ("templateClass.php");

Upvotes: 0

Related Questions