1--TEST-- 2Test fsockopen() function : error conditions 3--FILE-- 4<?php 5echo "*** Testing fsockopen() : basic error conditions ***\n"; 6 7echo "\n-- Attempting to connect to a non-existent socket --\n"; 8$hostname = 'tcp://127.0.0.1'; // loopback address 9$port = 31337; 10$errno = null; 11$errstr = null; 12$timeout = 1.5; 13var_dump( fsockopen($hostname, $port, $errno, $errstr, $timeout) ); 14var_dump($errstr); 15 16echo "\n-- Attempting to connect using an invalid protocol --\n"; 17$hostname = 'invalid://127.0.0.1'; // loopback address 18$port = 31337; 19$errno = null; 20$errstr = null; 21$timeout = 1.5; 22var_dump( fsockopen($hostname, $port, $errno, $errstr, $timeout) ); 23var_dump($errstr); 24 25echo "Done"; 26?> 27--EXPECTF-- 28*** Testing fsockopen() : basic error conditions *** 29 30-- Attempting to connect to a non-existent socket -- 31 32Warning: fsockopen(): Unable to connect to tcp://127.0.0.1:31337 (%a) in %s on line %d 33bool(false) 34string(%d) "%a" 35 36-- Attempting to connect using an invalid protocol -- 37 38Warning: fsockopen(): Unable to connect to invalid://127.0.0.1:31337 (Unable to find the socket transport "invalid" - did you forget to enable it when you configured PHP?) in %s on line %d 39bool(false) 40string(100) "Unable to find the socket transport "invalid" - did you forget to enable it when you configured PHP?" 41Done 42