RE: [PHP-WIN] PHP My first function (help)!!!!

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

 



> You cannot use comparision operaters (<=, >=, >) with strings. 
> When you put quotes around your variable it defines it to 
> php as a string, which translated means that it's words, not
> numbers.  So you could say 

> if ("$total" == "lowprice") {
>   code code code
> }
> 
> but not say ("$total" >= 25) {
>   code code code
> }

In fact you can say that, since php is type less and does implicit
casting, it will evaluate it as integer comparisment in both cases.
 
> Also, you have defined your intergers as strings. 

Which is not a good practice, but it will work,
since php will keep track on the casting.

> You're much better off with comparision operators using only
> intergers  rather than comparing two strings that should be intergers.

I agree with you.




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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux