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