PHP 4.0 Bug #5652:

From: Date: Tue, 18 Jul 2000 08:18:56 +0000
Subject: PHP 4.0 Bug #5652:
Groups: php.dev 
Request: Send a blank email to php-dev+get-24852@lists.php.net to get a copy of this message
From: christoffer@leitet.no Operating system: linux 2.2.16 PHP version: 4.0.0 PHP Bug Type: Misbehaving function Bug description: I've made a function that asks whoisservers for information: <? $WhoIsServer="whois.nic.as"; $fp = fsockopen ("$WhoIsServer", 43, $errnr, $errstr); set_socket_blocking($fp,0); fputs($fp, "$domain\n"); // Open a connect while (!feof($fp)) { $result = fgets($fp, 2048); $test = ereg_replace(10, " ", $result); // I've tried both ereg_replace(), stripslashes(), stripcslashes() and str_replace() (only ereg_replace and str_replace has worked the way I want) print substr("$result",0,4); if (substr("$test" ,12,8) == "Server") { //Hvis ledig echo "$MsgFree"; } else if (substr("$test" ,0, 6) == "Rights") { // Hvis opptatt printf ("$MsgTaken"); } } fclose($fp); // Close } ?> When I output the str_replaced string with print, printf and echo, it is all on one line without newlines (I've tried both with \n and ASCII character 10 to represent the newline). But when I use substr($test, 0,12) fx. then it output the twelveth first characters in every line in the original string ($result). When I use substr($test, 2,4), it outputs the 2nd to 4th character in every line in the original $result instead of printing the 2nd to 4th character in the new string that shouldn't contain any newlines. I use a standard php.ini, and has no unique setup. I've tried this out on both 3.0.16 and 4.0.0

« previous php.dev (#24852) next »