Freeing Memory PHP

Each time you create a variable, system memory is set aside for it. Although there is a limit to the memory available to any computer, you will rarely need to consider conserving its use when programming in PHP. Your scripts are likely to use very small amounts of data. And when your script finishes, the memory needed for variables is freed for use by other processes.

I am simplifying the process somewhat. There are some ways in PHP to create memory that persists longer than a single page load, and in modern operating systems physical memory does not match one-for-one with a program's view of available memory. In most cases you will be doing fine to consider that memory is a finite but abundant resource.

If you do run into memory shortages, or have some other reason for destroying a variable, you use the unset statement. This statement completely removes a variable or an array element from memory. The variable name itself will no longer be recognized. Paired with this statement is the isset function discussed in Chapter 9. This function returns TRUE when a variable exists.



Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

PHP Topics