Re: Problem with inserting numbers...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le 11/08/2011 13:08, Tamara Temple a écrit :

On Aug 10, 2011, at 8:22 PM, Jason Pruim wrote:
while ($num != "10000") {

Problem is here ^ You are testing a numeric $num with a string "10000", which $num will *never* equal. Leave off the quotes on the number.

Hum, I suggest you read this page properly :
http://www.php.net/manual/en/types.comparisons.php

exemple :

<?php
$num = 1;
$num++;
print ($num != 2 ? "different" : "equal") . PHP_EOL . ($num != "2" ? "different" : "equal") . PHP_EOL; print ($num !== 2 ? "different" : "equal") . PHP_EOL . ($num !== "2" ? "different" : "equal") . PHP_EOL;

result :

equal
equal
equal
different


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux