|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-04-17 14:19 UTC] hotmail22a23 at hotmail dot com
[2011-04-17 14:20 UTC] account22a23 at hotmail dot com
[2011-04-17 15:05 UTC] cataphract@php.net
-Type: Bug
+Type: Documentation Problem
[2011-04-17 15:05 UTC] cataphract@php.net
[2011-04-26 21:29 UTC] salathe@php.net
[2011-04-26 21:30 UTC] salathe@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: salathe
[2011-04-26 21:30 UTC] salathe@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 16:00:01 2025 UTC |
Description: ------------ While the code below may have other problems, the simple fact of the matter is that when I uncomment "$int--;" and comment "$int -= '1';" the code will loop for at least a minute, but when it is left as is below it does not and will terminate as expected. Since I've been told the two pieces of code have the exact same logic, I have no explaination for this. Please contact me if you know why. The php package was installed using 'yum install php php-mysql' on fedora 14. Test script: --------------- <?php function GeneratePassword($int, $string){ $new_string = ''; while ($int >= 0){ $new_string += $string[rand(0, (strlen($string) - 1))]; //$int--; $int -= '1'; echo 'round'; echo 'dump of int: ' . var_dump($int); echo 'dump of string: ' . var_dump($string); echo 'dump of new_string: ' . var_dump($new_string); } return ($new_string); } fwrite(STDOUT, "Choose an int"); $int = fgets(STDIN); fwrite(STDOUT, "Choose a string"); $string = fgets(STDIN); $pass = GeneratePassword($int, $string); echo 'anything'; echo $pass; ?> Actual result: -------------- CASE 1 USING: //$int--; $int -= '1'; ------------------------------------------------------ php -f delete_me2.php Choose an int2 Choose a stringbb roundint(1) dump of int: string(3) "bb " dump of string: int(0) dump of new_string: roundint(0) dump of int: string(3) "bb " dump of string: int(0) dump of new_string: roundint(-1) dump of int: string(3) "bb " dump of string: int(0) dump of new_string: anything0 CASE 2 USING: $int--; //$int -= '1'; ------------------------------------------------------ php -f delete_me2.php Choose an int2 Choose a stringbb roundstring(2) "2 " dump of int: string(3) "bb " dump of string: string(0) "" dump of new_string: roundstring(2) "2 " dump of int: string(3) "bb " dump of string: string(0) "" dump of new_string: roundstring(2) "2 " dump of int: string(3) "bb " dump of string: string(0) "" dump of new_string: roundstring(2) "2 " dump of int: string(3) "bb " dump of string: string(0) "" dump of new_string: roundstring(2) "2 " dump of int: string(3) "bb " dump of string: string(0) "" dump of new_string: roundstring(2) "2 " dump of int: string(3) "bb " dump of string: string(0) "" dump of new_string: roundstring(2) "2 " dump of int: string(3) "bb " dump of string: string(0) "" dump of new_string: roundstring(2) "2 " dump of int: string(3) "bb " dump of string: string(0) "" dump of new_string: roundstring(2) "2 " dump of int: string(3) "bb " dump of string: string(0) "" dump of new_string: roundstring(2) "2 " dump of int: string(3) "bb " dump of string: string(0) "" dump of new_string: roundstring(2) "2 " dump of int: string(3) "bb " dump of string: string(0) "" dump of new_string: roundstring(2) "2 " ... (loops for at least 60 seconds) ...