Jonathan
Jonathan

Reputation: 11321

How can I tell what my php script is doing before it finishes loading?

I have a simple php program that analyzes a text (here's the source on github, and here's a somewhat-working demo), but it's excruciatingly slow. Since I'm a beginning programmer, I'm not sure what I'm doing wrong. In python or something, I'd print out debugging messages every step of the way while the program was running, but with php, I don't seem to get any messages until the entire script has run its course. How can I output useful debugging information before the script has finished running, so I can tell which functions are taking the longest time?

Upvotes: 0

Views: 80

Answers (2)

Pitchinnate
Pitchinnate

Reputation: 7556

You can use ob_flush() and flush() to send data as the code is running:

echo "status message 1";
ob_flush();flush();

Upvotes: 1

A P
A P

Reputation: 457

you can always flush() all output buffer

Upvotes: 0

Related Questions