Jump to content

Recommended Posts

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!

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.

  • Great Answer 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.