0

The server has various modules loading running and exiting within a session, until output to the client. My class is a plugin to a popular helpdesk system and I do not have access to modify other system files to enable ob_start().

  • Module #1
  • Module #2
  • Module #3
  • Module #4
  • Module #5 <- my class include_once here

My class needs the HTML that has accumulated by the previous modules, which will later be sent to the client.

ob_start() is not very useful in my situation since I would have to go and modify some module up the chain and add ob_start(); before it begins. We have to bear in mind that I can only work within my module

8
  • You want output buffering, see the examples in the manual. Also read: What is output buffering?. Commented Jul 21, 2020 at 16:19
  • 1
    Does this answer your question? What is output buffering? Commented Jul 21, 2020 at 16:20
  • Not very useful in my situation since I would have to go and modify some module up the chain and add ob_start(); before it begins. We have to bear in mind that I can only work within my module. Commented Jul 21, 2020 at 16:47
  • Presuming the other modules don't fiddle with the output buffer, can't you just turn output buffering on at the source (= whatever that's calling all those modules)? Or, are you saying you have no control over anything except your own module? I see you updated the question to say just that. In that case, this question isn't a duplicate, and could be reopened. Commented Jul 21, 2020 at 16:52
  • In other words, this isn't running on your own server -- but instead you're providing a module that others will be using with their own server and installation of the main app, and therefore you have no control? Commented Jul 21, 2020 at 16:53

1 Answer 1

1

I think you would be interested in "output buffering" here is a link to PHP's documentation on the matter.


    // Start buffering the output
    ob_start();

    //... do a bunch of stuff, which will generate output
    // require/include any additional scripts too

    /**

       $output will contain all content which was outputted
       
    */
    $output = ob_get_clean();

    echo $output;// send the content to stdout... to the browser.


Sign up to request clarification or add additional context in comments.

8 Comments

Not very useful in my situation since I would have to go and modify some module up the chain and add ob_start(); before it begins. We have to bear in mind that I can only work within my module.
So you want to capture content, already sent to the browser, prior to your module running?
I would not recommend doing this, unless your module will only ever run on your projects, as it would be very intrusive. Assuming modules are loaded prior to being used, such as the case with composer, you could hijack the entire request, by starting the output buffering when your module is loaded... It would not effect the functionality of other modules, but may change the output behavior of the request...
What is the help system, you are using?
I looked at osTicket's source, and I may be mistaken, I've not installed the source or tested it, but if your module, is bootstrapped along with the rest of the system, you can start output buffering in your plugin's bootstrap function... And then capture the output, in your module and process/inspect it as you please, you will just need to ensure you eventually dump it to the browser.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.