In PHP, ftp_get_option() reads one of the runtime settings of an open FTP connection. It tells you the current timeout, whether auto-seek is on, and whether the server's passive address is used.
Think of it as the "read" partner of ftp_set_option(). You pass the connection and one option constant, and PHP gives you the current value back, so you can check a setting before you change it.
Syntax
Call ftp_get_option() with the values you need. Start with this line.
PHP
$timeout = ftp_get_option($ftp, FTP_TIMEOUT_SEC);
Call
What it does
ftp_get_option($ftp, FTP_TIMEOUT_SEC)
Returns the network timeout in seconds as an int (the default is 90).
ftp_get_option($ftp, FTP_AUTOSEEK)
Returns true or false depending on whether auto-seek is enabled.
ftp_get_option($ftp, FTP_USEPASVADDRESS)
Returns true if PHP uses the IP address the server sends in passive mode.
Only three options are supported: FTP_TIMEOUT_SEC, FTP_AUTOSEEK and FTP_USEPASVADDRESS. In PHP 8, any other value throws a ValueError. The first argument is an FTP\Connection object, not a resource.
Library declarations
PHP
ftp_get_option(FTP\Connection $ftp, int $option): int|bool
Parameters
Parameter
Description
ftp
Required. The FTP\Connection object returned by ftp_connect() or ftp_ssl_connect().
option
Required. One of FTP_TIMEOUT_SEC, FTP_AUTOSEEK or FTP_USEPASVADDRESS.
Return Value
Return Value
Description
int
The timeout in seconds when you ask for FTP_TIMEOUT_SEC.
bool
true or false when you ask for FTP_AUTOSEEK or FTP_USEPASVADDRESS.
PHP Examples
Example 1 — Read the Default Timeout
Connect to a server and print the timeout that PHP uses for network operations.