| re: ftp_quit($conn_id) necessary?
Markus Ernst wrote:[color=blue]
> I have a question that I don't find answered in the manual: After
> opening an ftp connection with PHP, will it be closed automatically
> after the script is executed, just as MySQL connections are? Or does
> it remain open unless it is terminated with ftp_quit?
>
> The background is that I wrote some functions that go through the
> directory structure and do for example some CHMODing. The functions
> call themselves if they find a directory, so I can't close the
> connection at the end of the function executing:
>[/color]
You could add a ftp_disconnect() method, which you call at the end of your
script.
Anyways, even when you don't close the ftp resource at the end of the
script, PHP's garbage collector will get rid of it when it finishes parsing
the script.
But closing the connection when you are done is good programming practice,
so just add the ftp_disconnect() method to your class and put a call to it
right at the bottom of your script. In PHP 5 you can even add a
"__destruct()" method in your class, in which you call ftp_close(). This
method is called automatically when the script finishes.
JW |