如何在加载完成之前告诉我的php脚本在做什么?

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?

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

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

you can always flush() all output buffer