PHP sleep function causes Terminated Execution Timed Out! Why?
I tried to add a little delay into my code but it doesn't work. This code works perfectly on w3schools.com. Am I doing something wrong? https://code.sololearn.com/wJdfKVKhtpQZ/?ref=app
Josh Greig got it 👍 thanks again!
Thank you Josh Greig for your answer. Sounds like you have a point but then why setTimeout works perfectly in JS? There's a lot of web codes that have infinite loops and they run here without errors. Of course Sololearn freezes and you have to close the app. When the argument is less than 1 sleep ignored at all. I will email Sololearn if nobody knows what's wrong here. However people say that Sololearn staff is very busy and might not respond if the problem is not very serious. Lastly. I don't want to experiment with sleep. It's not very useful or important. After all my codes codes work fine without it. All wanted was to make my PHP codes work like my JS codes. Also it would be nice to split some large output into smaller print outs using some short time delays.
The Sololearn staff will know for sure but I'm confident they put an execution time limit on the script. Apparently, that limit is roughly 1 second. CPU processing time costs money and they need to cut an infinite loop short. 1 second appears to be where they draw the line. If you didn't sleep, you could do a lot of processing in 1 second so it is a pretty generous time limit. You can email [email protected] your question if you want to hear from one of them. If you want to experiment lots with sleep, I suggest you install WAMP or XAMPP on your laptop or desktop and run scripts there. Running the script locally will let you learn more about how it executes and give you enough flexibility to make a complete website or web application. It also helps you access detailed logs that help you troubleshoot problems. If you run Windows, you can get WAMP from: https://www.wampserver.com/en/