xref: /PHP-8.3/ext/ftp/tests/ftp_get_option.phpt (revision e9f783fc)
1--TEST--
2Testing ftp_get_option basic functionality
3--CREDITS--
4Gabriel Caruso (carusogabriel34@gmail.com)
5--EXTENSIONS--
6ftp
7pcntl
8--FILE--
9<?php
10require 'server.inc';
11define('FOO_BAR', 10);
12
13$ftp = ftp_connect('127.0.0.1', $port);
14ftp_login($ftp, 'user', 'pass');
15$ftp or die("Couldn't connect to the server");
16
17var_dump(ftp_get_option($ftp, FTP_TIMEOUT_SEC));
18var_dump(ftp_get_option($ftp, FTP_AUTOSEEK));
19var_dump(ftp_get_option($ftp, FTP_USEPASVADDRESS));
20
21try {
22    ftp_get_option($ftp, FOO_BAR);
23} catch (ValueError $exception) {
24    echo $exception->getMessage() . "\n";
25}
26
27?>
28--EXPECTF--
29int(%d)
30bool(true)
31bool(true)
32ftp_get_option(): Argument #2 ($option) must be one of FTP_TIMEOUT_SEC, FTP_AUTOSEEK, or FTP_USEPASVADDRESS
33