Parse PHP, capture output and use as string??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • petethebloke@googlemail.com

    #1

    Parse PHP, capture output and use as string??

    I'm not sure what to search the web for, so I wonder if someone here
    can help me?

    I have a website that uses many individual php pages. I'd like to
    simplify design updates by using these scripts as includes, but I'm
    trying to avoid having loads of:

    $output_string. ="<tr><td>bl ah blah".$some_var iable;
    $output_string. ="blah blah</td></tr>";

    You know the kinda thing.

    Is there a way of parsing the script in the php processor and then
    capturing the string created and dropping it into my templating script?

    Thanks

    Pete

  • petethebloke@googlemail.com

    #2
    Re: Parse PHP, capture output and use as string??

    I think I've answered my own question.

    //at the start of the page I put....
    ob_start();

    //and at the end I put......
    $output_string= ob_get_contents ();
    ob_end_clean();

    Seems to work, but if you know better then please say so.

    Pete

    Comment

    • B.r.K.o.N.j.A

      #3
      Re: Parse PHP, capture output and use as string??

      petethebloke@go oglemail.com wrote:
      I think I've answered my own question.
      >
      //at the start of the page I put....
      ob_start();
      >
      //and at the end I put......
      $output_string= ob_get_contents ();
      ob_end_clean();
      >
      Seems to work, but if you know better then please say so.
      >
      Pete
      >
      That should be ok, I'm using it as a base for my templating engine and I
      had no problems so far.

      --

      B.r.K.o.N.j.A = Bionic Robotic Knight Optimized for Nocturnal Judo and
      Assasination

      Comment

      Working...