已知最新文章編號 $last,以 ARTICLE 指令逐篇讀取:
<?php
$cfgLimit = 10;
for ($boucle = $last - $cfgLimit; $boucle <= $last; $boucle++) {
set_time_limit(0);
fputs($usenet_handle, "ARTICLE $boucle\n");
$article = '';
$tmp = fgets($usenet_handle, 4096);
if (substr($tmp, 0, 3) != '220') {
echo \"Error on article $boucle\n\";
} else {
while ($tmp != \".\r\n\") {
$tmp = fgets($usenet_handle, 4096);
$article .= $tmp;
}
echo \"Article $boucle\n$article\";
}
}
?>
亦可用 HEAD 只讀標頭、BODY 只讀內文。
<?php
fclose($usenet_handle);
?>