Home > Article > Backend Development > PHP sets the maximum execution time of code
phpWhen certain operations are completed, it may take a long time to execute. This requires setting its execution time, otherwise the server will stop execution after the execution time times out and the page will be blank. Two solutions are recommended below:
1.php file page settings:
<?php //修改最大执行时间 <a href="https://www.baidu.com/s?wd=ini_set&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YdPvnsn10LPHnvnvnYrA7h0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHfsnj04njc1" target="_blank" class="baidu-highlight">ini_set</a>('max_execution_time', '0'); //修改此次最大<a href="https://www.baidu.com/s?wd=%E8%BF%90%E8%A1%8C%E5%86%85%E5%AD%98&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YdPvnsn10LPHnvnvnYrA7h0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHfsnj04njc1" target="_blank" class="baidu-highlight">运行内存</a> <a href="https://www.baidu.com/s?wd=ini_set&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YdPvnsn10LPHnvnvnYrA7h0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHfsnj04njc1" target="_blank" class="baidu-highlight">ini_set</a>('memory_limit','128M'); /*** * * 代码块省略...... * * */ ?>
php.iniConfiguration file settings (specific values, set as needed):
max_execution_time = 60
memory_limit = 128M
##Note: If the execution memory is completely satisfied, then No need to set it up. Specific settings can be set flexibly according to the situation.The above is the detailed content of PHP sets the maximum execution time of code. For more information, please follow other related articles on the PHP Chinese website!