1--TEST-- 2Test imap_fetchheader() function : usage variations - $message_num argument 3--SKIPIF-- 4<?php 5require_once(__DIR__.'/setup/skipif.inc'); 6?> 7--FILE-- 8<?php 9/* 10 * Pass different integers and strings as $message_num argument 11 * to test behaviour of imap_fetchheader() 12 */ 13 14echo "*** Testing imap_fetchheader() : usage variations ***\n"; 15 16require_once(__DIR__.'/setup/imap_include.inc'); 17 18$stream_id = setup_test_mailbox('imapfetchheadervar5', 3, $mailbox, false); // set up temp mailbox with 3 msgs 19 20$sequences = [0, /* out of range */ 4, 1]; 21 22foreach($sequences as $message_num) { 23 echo "\n-- \$message_num is $message_num --\n"; 24 try { 25 var_dump(imap_fetchheader($stream_id, $message_num)); 26 } catch (\ValueError $e) { 27 echo $e->getMessage() . \PHP_EOL; 28 } 29} 30 31// clear error stack 32imap_errors(); 33?> 34--CLEAN-- 35<?php 36$mailbox_suffix = 'imapfetchheadervar5'; 37require_once(__DIR__.'/setup/clean.inc'); 38?> 39--EXPECTF-- 40*** Testing imap_fetchheader() : usage variations *** 41Create a temporary mailbox and add 3 msgs 42New mailbox created 43 44-- $message_num is 0 -- 45imap_fetchheader(): Argument #2 ($message_num) must be greater than 0 46 47-- $message_num is 4 -- 48 49Warning: imap_fetchheader(): Bad message number in %s on line %d 50bool(false) 51 52-- $message_num is 1 -- 53string(%d) "From: foo@anywhere.com 54Subject: Test msg 1 55To: %s 56MIME-Version: 1.0 57Content-Type: MULTIPART/mixed; BOUNDARY="%s=:%d" 58 59" 60