Doc #54222 [Opn->Wfx]: comparing 2 strings, when 1 string is numeric
| From: | frozenfire@php.net | Date: | Sat, 02 Jul 2011 08:22:27 +0000 |
| Subject: | Doc #54222 [Opn->Wfx]: comparing 2 strings, when 1 string is numeric | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-6809@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=54222&edit=1
ID: 54222
Updated by: frozenfire@php.net
Reported by: delphists at apollo dot lv
Summary: comparing 2 strings, when 1 string is numeric
-Status: Open
+Status: Wont fix
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
The purpose of the type comparison documentation is to describe and explain the
comparison casting precedence order, among other things. Any confusion as to this
order, in most cases, is simply a matter of not having read the material closely
enough.
I don't think further clarification is necessary.
Previous Comments:
------------------------------------------------------------------------
[2011-03-11 10:02:01] delphists at apollo dot lv
Description:
------------
Link: http://www.php.net/manual/en/types.comparisons.php
It's written that "If (..) the comparison involves numerical strings, then each string is
converted to a number and the comparison performed numerically." After reading this, some
(e.g., me) may think that both strings are converted if *any* of involved strings is numeric, so
'2abc' == '2' would have to return true rather than false.
To avoid such misunderstandings, I would advise to change this sentence to something like this:
* "If you compare a number with a string, a string with a number or a numerical string with
another numerical string, then each string is converted to a number and the comparison performed
numerically."
* "If you compare a number with a string, a string with a number or two numerical strings, then
each string is converted to a number and the comparison performed numerically."
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=54222&edit=1