Hello Php coders !
when you have wide Php scripts,
not enough memory can crash your script if they reach the high limit of memory, then your script is 'out of memory'.
in Php purposes,
it exists one function to unload explicitely some vars.
let's see :
when you have no more needs with vars along your script, 'unset( $var ) ;' will save free memory.
It's a high skill habits .
www.w3schools.com
www.php.net
It's more :
one right good habit !
Try it !
when you have wide Php scripts,
not enough memory can crash your script if they reach the high limit of memory, then your script is 'out of memory'.
in Php purposes,
it exists one function to unload explicitely some vars.
let's see :
PHP:
<?php
// 'arrays' , 'objects' , 'php native objects' and wide 'string' could be heavy weighted.
// used in a loop , or along one script.
// the Php script RAM amount required is on a 'growth' by every loop achieved.
$obj = new lambda_but_RAM_glutton(); // ::new var, an object.
while( $waiting_for_loop_end() ){
$obj->_add_collection( $big_collection ); // ::using the var , with increasing ram used mulitple times.
}
// $obj takes more and more memory at every loop
// by one function : 'unset($___)'; , you will operate one explicit 'free() on memory'
unset($obj); // ::destruction of the var because of no more need for all following instructions
// the '$obj' var will be deleted from memory in use,
// the available memory for the script will gain __free space__ , that's so useful !
?>
when you have no more needs with vars along your script, 'unset( $var ) ;' will save free memory.
It's a high skill habits .
PHP:
<?php
// syntaxt for several VARS :
unset( $some , $multiple , $vars , $to_free , $from_memory ) ;
// syntax for one VAR :
unset( $var ) ;
?>

W3Schools.com
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

PHP: unset - Manual
PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.
It's more :
- 'explicit memory management',
- higher quality of your Php scripts,
- safer execution within your Php scripts.
one right good habit !
Try it !
Last edited: