php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16568 string comparison features give opposing results
Submitted: 2002-04-12 10:46 UTC Modified: 2002-04-12 11:32 UTC
From: lent at fstrf dot org Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.1.2 OS: SunOS 5.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lent at fstrf dot org
New email:
PHP Version: OS:

 

 [2002-04-12 10:46 UTC] lent at fstrf dot org
NOTE: in the examples below the $myrow array is a string array populated by an ingres select statement.

if $myrow[6] is null going into the first example then 
$myrow[6] will not be set to &npsp, but in the second example it will.  Shouldn't these two examples be equivalent?  Also strcmp function behaves like example 1.


EXAMPLE 1:

trim($myrow[6]);
($myrow[6]) == " " ? $myrow[6] = " ")

EXAMPLE 2:

trim($myrow[6]);
(ord($myrow[6]) == 32 ? $myrow[6] = " ");


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-12 11:11 UTC] sniper@php.net
The bug system is not the appropriate forum for asking support
questions. For a list of a range of more appropriate places to ask
for help using PHP, please visit http://www.php.net/support.php
 [2002-04-12 11:16 UTC] lent at fstrf dot org
I'm not asking a support question.

$myrow[6] is an empty string.

ord($myrow[6]) returns 32 (ascii for ' ')

the first character of an empty string shouldn't evaluate as ascii 32.  So this is a bug.
 [2002-04-12 11:32 UTC] sander@php.net
$myrow[6] is not an empty string because you're trim()'ing the string incorrectly. See http://www.php.net/manual/en/function.trim.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 01:01:27 2024 UTC