Click here to Skip to main content
15,915,093 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
AnswerRe: PHP with ODBC Connectivity Pin
whatrevolution28-Jun-10 21:40
whatrevolution28-Jun-10 21:40 
QuestionHelp with this expression Pin
xx77abs4-Jun-10 2:59
xx77abs4-Jun-10 2:59 
AnswerRe: Help with this expression Pin
cjoki4-Jun-10 5:29
cjoki4-Jun-10 5:29 
GeneralRe: Help with this expression Pin
xx77abs4-Jun-10 5:34
xx77abs4-Jun-10 5:34 
GeneralRe: Help with this expression Pin
cjoki6-Jun-10 9:42
cjoki6-Jun-10 9:42 
GeneralRe: Help with this expression Pin
xx77abs6-Jun-10 10:22
xx77abs6-Jun-10 10:22 
GeneralRe: Help with this expression Pin
cjoki7-Jun-10 2:20
cjoki7-Jun-10 2:20 
GeneralRe: Help with this expression Pin
cjoki7-Jun-10 5:25
cjoki7-Jun-10 5:25 
and php does force a conversion of strings when they appear in a comparisons

If you compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison performed numerically. These rules also apply to the switch statement. The type conversion does not take place when the comparison is === or !== as this involves comparing the type as well as the value.


source: http://www.php.net/manual/en/language.operators.comparison.php[^]

I also noted that on this page that speaks to comparisons they have the following sample code
<?php
var_dump(0 == "a"); // 0 == 0 -> true
var_dump("1" == "01"); // 1 == 1 -> true
var_dump("10" == "1e1"); // 10 == 10 -> true
var_dump(100 == "1e2"); // 100 == 100 -> true

switch ("a") {
case 0:
    echo "0";
    break;
case "a": // never reached because "a" is already matched with 0
    echo "a";
    break;
}
?> 


So even the manual supports the "a" == 0, but I can not find out exactly why it does this.

The questions I now have is does the function used in the conversion return a zero as a result or is this an error from the function which also returns a zero?
GeneralRe: Help with this expression Pin
xx77abs11-Jun-10 6:32
xx77abs11-Jun-10 6:32 
AnswerRe: Help with this expression PinPopular
User 17164924-Jun-10 6:33
professionalUser 17164924-Jun-10 6:33 
GeneralRe: Help with this expression Pin
cjoki6-Jun-10 9:45
cjoki6-Jun-10 9:45 
GeneralRe: Help with this expression Pin
xx77abs6-Jun-10 10:08
xx77abs6-Jun-10 10:08 
GeneralRe: Help with this expression Pin
whatrevolution22-Jun-10 23:52
whatrevolution22-Jun-10 23:52 
AnswerRe: Help with this expression Pin
whatrevolution23-Jun-10 0:13
whatrevolution23-Jun-10 0:13 
QuestionCloning a XLS worksheet in PHP Pin
Bijayani31-May-10 23:47
Bijayani31-May-10 23:47 
AnswerRe: Cloning a XLS worksheet in PHP Pin
Kristian Sixhøj3-Jun-10 7:29
Kristian Sixhøj3-Jun-10 7:29 
AnswerRe: Cloning a XLS worksheet in PHP Pin
Richard MacCutchan3-Jun-10 8:40
mveRichard MacCutchan3-Jun-10 8:40 
QuestionLearning Linux Pin
pc.bharti27-May-10 23:33
pc.bharti27-May-10 23:33 
AnswerRe: Learning Linux Pin
Richard MacCutchan28-May-10 0:10
mveRichard MacCutchan28-May-10 0:10 
GeneralRe: Learning Linux Pin
wbgxx21-Jun-10 3:58
wbgxx21-Jun-10 3:58 
AnswerRe: Learning Linux Pin
Iranian MM7-Sep-11 6:51
Iranian MM7-Sep-11 6:51 
QuestionPHP DOM Pin
vho12320-May-10 4:50
vho12320-May-10 4:50 
AnswerRe: PHP DOM Pin
Graham Breach20-May-10 7:06
Graham Breach20-May-10 7:06 
QuestionManaging a database insert failure.. Pin
MacIntyre19-May-10 4:57
MacIntyre19-May-10 4:57 
AnswerRe: Managing a database insert failure.. [modified] Pin
Dr.Walt Fair, PE19-May-10 5:26
professionalDr.Walt Fair, PE19-May-10 5:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.