Ervin Posted June 22 Share Posted June 22 What is the best and correct solution for delete variables? I run script d:\php\php.exe -f script.php on win11. This script run 24h. If the best and correct solution: for ($zanke = 1; ; $zanka++) { set_time_limit (0); $data=file_get_contents("http://localhost:5897/x/query.cgi?q=status"); if(preveri($data)) { shrani($data); poslji($data); } sleep (5); flush(); $data=""; $zanka = 0; } or: for ($zanke = 1; ; $zanka++) { set_time_limit (0); $data=file_get_contents("http://localhost:5897/x/query.cgi?q=status"); if(preveri($data)) { shrani($data); poslji($data); } sleep (5); $vars = array_keys(get_defined_vars()); for ($i = 0; $i < sizeOf($vars); $i++) { unset($$vars[$i]); } unset($vars,$i); ali pa: $vars = array_keys(get_defined_vars()); foreach($vars as $var) { unset(${"$var"}); } $zanka = 0; } Thank you for help! Quote Link to comment https://forums.phpfreaks.com/topic/328941-best-and-correct-solution-for-delete-variables/ Share on other sites More sharing options...
requinix Posted June 22 Share Posted June 22 Don't. PHP isn't a low-level language like C. You don't have to manage memory like that. PHP has some very smart internal logic and is perfectly capable of handling creating and destroying variables on your behalf. So let it do what it knows how to do. 1 Quote Link to comment https://forums.phpfreaks.com/topic/328941-best-and-correct-solution-for-delete-variables/#findComment-1655348 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.