#12: Extending the Run Time of a Script

At one point, the company I work for changed its online shopping carts, forcing me to write a script to convert 250MB of stored product data from the old cart's format into the new cart's format. The script worked perfectly, but I was evaluating and transforming so much data that PHP kept timing out my program after 30 seconds, long before it had a chance to finish.

That's when I discovered a handy-dandy little extension that allowed me to get the job done. The following line, when added to the beginning of a script, allows the script to take up to 240 seconds to finish.

ini_set(max_execution_time, "240");

The max_execution_time configuration parameter controls the longest allowable time a script is allowed ...

Get Wicked Cool PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.