note 57136 added to function.imagedestroy
| From: | roland at more-pc dot nl | Date: | Sun, 25 Sep 2005 01:31:18 +0000 |
| Subject: | note 57136 added to function.imagedestroy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-95731@lists.php.net to get a copy of this message | ||
As Andrew states below, it's IMPERATIVE that you use the imagedestroy() function. But your
script may abort before it reaches the call to imagedestroy() (for example the user may click the
browsers 'stop' button). In this case the default PHP behaviour is to abort the script,
never reaching your call to imagedestroy().
One way of doing it (the one which works very well for me) is with register_shutdown_function():
<?
function shutdown_func() {
global $img;
if($img)
imagedestroy($img);
}
register_shutdown_function("shutdown_func");
$img = imagecreate...(...);
... // manipulate image
// normally I'd need the following line, but now it's handled by shutdown_func()
// imagedestroy($img);
?>
----
Manual Page -- http://www.php.net/manual/en/function.imagedestroy.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57136
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57136&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57136&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57136&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57136&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57136&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57136&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57136&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57136&report=yes
Search -- http://master.php.net/manage/user-notes.php