简体   繁体   中英

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?

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

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

你总是可以flush()所有输出缓冲区

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM