php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54222 comparing 2 strings, when 1 string is numeric
Submitted: 2011-03-11 10:02 UTC Modified: 2011-07-02 04:22 UTC
From: delphists at apollo dot lv Assigned:
Status: Wont fix Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-03-11 10:02 UTC] 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."



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-02 04:22 UTC] frozenfire@php.net
-Status: Open +Status: Wont fix
 [2011-07-02 04:22 UTC] frozenfire@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 19:01:31 2024 UTC