From c0a982bd4336b90ac9cfc780f13394945dbb7b99 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Fri, 6 Aug 2004 19:13:20 +0000 Subject: [PATCH] Comparison of numerical strings (bug #23110) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@165552 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/operators.xml | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/language/operators.xml b/language/operators.xml index 660fb677aa..5dad563dba 100644 --- a/language/operators.xml +++ b/language/operators.xml @@ -1,5 +1,5 @@ - + Operators @@ -461,6 +461,32 @@ echo "hallo" ^ "hello"; // Outputs the ascii values #0 #4 #0 #0 #0 + + If you compare integer with the string, the string is + converted to number. + If you compare two numerical strings, they are compared as integers. These + rules are valid also for the + switch statement. + + + true +var_dump("1" == "01"); // 1 == 1 -> true + +switch ("a") { +case 0: + echo "0"; + break; +case "a": // never reached because "a" is already matched with 0 + echo "a"; + break; +} +?> +]]> + + + Another conditional operator is the "?:" (or ternary) operator.