In PHP if I set the the memory 100M via ini_set
and then I set set_time_limit(0);
Does that mean that my PHP memory allocation is 100M forever(Until I restart my Apache)?
No its reset back to the original at the end of script execution.
string ini_set ( string $varname , string $newvalue )
Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.
and set_time_limit(0);
is treated the same.
Example:
// 1. Script starts
echo ini_get('memory_limit');//128M
// 2. We set a new limit the script will now have 100M
ini_set('memory_limit','100M');
echo ini_get('memory_limit'); //100M
die;
// 3. Script ends now its set back to 128M
With set_time_limit(0);
it just tells the script to not time out, tho say you were to use set_time_limit(0);
within a loop then on each iteration its internal counter is set to 0 over and over.
So if you were to use set_time_limit(1);
within a loop as long as each iteration of the loop did not last longer then 1 second then it would still not time out as set_time_limit(n);
would reset the internal timeout counter to 0 on each iteration.
Example of it not timing out after 1 second:
for($i=0;$i<=10;$i++){
set_time_limit(1);
usleep(999998); //2micro seconds from a second
echo $i;
}