PHP 8.6.0RC7 available for testing

ftp_get_option

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

ftp_get_option — Retrieves various runtime behaviours of the current FTP connection

Description

function ftp_get_option(FTP\Connection $ftp, int $option): int|bool

This function returns the value for the requested option from the specified FTP connection.

Parameters

ftp

An FTP\Connection instance.

option

Currently, the following options are supported:

Supported runtime FTP options
FTP_TIMEOUT_SEC Returns the current timeout used for network related operations.
FTP_AUTOSEEK Returns true if this option is on, false otherwise.

Return Values

Returns the value of the requested option.

Errors/Exceptions

Throws a ValueError if option is not FTP_TIMEOUT_SEC, FTP_AUTOSEEK, or FTP_USEPASVADDRESS.

Changelog

Version Description
8.1.0 The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected.
8.0.0 A ValueError is now thrown if option is not supported; previously, an E_WARNING was emitted and false was returned.

Examples

Example #1 ftp_get_option() example

<?php
// Get the timeout of the given FTP connection
$timeout = ftp_get_option($ftp, FTP_TIMEOUT_SEC);
?>

See Also

+add a note

User Contributed Notes 1 note

up
1
elamrani dot sv dot laza at gmail dot com
6 years ago
Please note that you can use this function to get the value of FTP_USEPASSIVEADDRESS option also : 

<?php

$conn = ftp_connect("host");
$login = ftp_login($conn, "user", "password");

var_dump(ftp_get_option($conn, FTP_USEPASVADDRESS)); // true (which is the default value)

ftp_set_option($conn, FTP_USEPASVADDRESS, false); // change the value

var_dump(ftp_get_option($conn, FTP_USEPASVADDRESS)); // false

?>
To Top