Re: PDF_close problem
| From: | Rasmus Lerdorf | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: PDF_close problem | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-3339@lists.php.net to get a copy of this message | ||
> Problem:
> pdf_open() requires an already open file opened with fopen().
> If pdf_close() is called it calls PDF_close() which closes this
> file but the php3 variable isn't removed. Only the pdf document is
> destroyed. I wonder what happens when it is removed by php3 automatically?
>
> Example:
>
> $fp = fopen(....);
> $info = pdf_get_info(...);
> $pdf = pdf_open($fp, $info);
> // At this point we have an open file in $fp and
> // a pdf document in $pdf
> ....
> pdf_close($pdf);
> // Now the file is closed, the pdf document is removed
> // but the variable $fp is still there pointing to a
> // closed file :-(
>
> I wonder if that is problem?
So what if $fp is there and pointing to a closed file? There is no
difference between that and something like:
$fp = fopen();
fclose($fp);
The $fp variable still exists and has a value, but the file is closed.
How is that a problem?
The problem in your pdf_close() function was that you ended up closing the
file but not removing the file pointer from PHP's list of open files.
That meant that when someone called fclose() on it specifically, or when
PHP tried to clean up after you, it would try to fclose() a file that was
already closed.
-Rasmus
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net