Should variables be destroyed after script execution? [PHP]

Site pages are created from separate modules. Many variables are used, including flags. Should they be destroyed at the end of the script?
unset($var)


Answer 1, authority 100%

They will be destroyed anyway. And I think it’s more efficient than doing it by hand.
But closing files, network connections (working with the database is a different story, it is often easier to open a connection once and everyone uses it – it saves resources), manual memory allocation – this is a must.


Answer 2

I’ll add it. This is not quite an answer to the question, but I did find why it is for security purposes.

to set variables to zero.

licensed_file.php (let’s say encrypted etc)

<?
$c = 0;
$a = 1;
$user = array('mypasswd' => '12345');
define('DB_LOGIN', 'user1');
define('DB_PASSWD', 'passwd1');
define('LICENSE_CODE', '123123123123123');
?>

tester.php

<?
include 'licensed_file.php';
echo '<pre>';
print_r(get_defined_constants());
print_r(get_defined_vars());
echo '</pre>';
?>

Result:

Array
(
  ...
  [DB_LOGIN] => user1
  [DB_PASSWD] => passwd1
  [LICENSE_CODE] => 123123123123123
)
Array
(
  ...
  [c] => 0
  [a] => 1
  [user] => Array
    (
        [mypasswd] => 12345
    )
)

Conclusion: do not use constants in “any such” scripts, set variables to null. Yes, there are also get_defined_functions, get_declared_classes, get_class_methods. Those. if you really care, the script should be close to school pascal)