Jump to content

Setting the value of a variable to the content of file...


cgm225

Recommended Posts

I have a page I am included right now as such:

include PAGE_DIR . "/" . $this->getName() . "/" . $action . "View.php5";

 

However, I want to make a variable in my class called $this->content hold the contents of the file above so that I can echo the file contents like so:

echo $this->content;

 

Restated, how can I make $this->content = the contents of PAGE_DIR . "/" . $this->getName() . "/" . $action . "View.php5"

 

Thanks in advance!

Actually, if your view contains php which needs to be parsed (which it likely does) you would need to use output buffering.

 

<?php

  function getview($path) {
    ob_start();
    include $path;
    $ret = ob_get_contents();
    ob_end_clean();
    return $ret;
  }

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.