The imagedestroy() function is an inbuilt function in PHP which is used to destroy an image and frees any memory associated with the image.
bool imagedestroy( resource $image )
Parameters: This function accepts a single parameter $image which holds the name of image.
Return Value: This function returns TRUE on success and FALSE on failure.
Below examples illustrate the imagedestroy() function in PHP:
Example 1: Destroying image after using it.
$cropped variable is destroy by the end line and you can't access it after that line.
Example 2: Checking if the variable is destroyed.
PHP log will give a error as the variable is destroyed. PHP Warning: imagepng(): supplied resource is not a valid Image resource.
- How to get the function name inside a function in PHP ?
- PHP | Ds\Set contains() Function
- PHP | dir() Function
- CSS | url() Function
- PHP | exp() Function
- p5.js | arc() Function
- D3.js | d3.map.set() Function
- PHP | Ds\Map first() Function
- p5.js | mag() Function
- PHP Ds\Map sum() Function
- D3.js | d3.set.has() Function
- CSS | var() Function
- PHP | pos() Function
- PHP | key() Function
- D3.js | d3.hsl() Function
- PHP | Ds\Map get() Function
- PHP | end() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.