php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47138 Bug ==
Submitted: 2009-01-17 18:32 UTC Modified: 2009-01-17 18:40 UTC
From: angeli at faccat dot br Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.2CVS-2009-01-17 (CVS) OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: angeli at faccat dot br
New email:
PHP Version: OS:

 

 [2009-01-17 18:32 UTC] angeli at faccat dot br
Description:
------------
Brazil - Portugu?s

N?o realiza a igualdade.
Tenho um array serializado que busco na sess?o, quando realizo uma compara??o de um nodo do array com uma string est? retornando como se fosse igual, mas n?o s?o iguais (==).

O valor do array ? 0 (zero) do tipo integer, e quando fa?o uma compara??o (==) com uma string retorna true. Se fa?o a compara??o com inteiro realiza corretamente a valida??o.

Se eu realizo um trim() no array e fa?o a igualdade, ai realiza corretamente. Fiz um strlen() no array e o tamanho ? 1.

Se fa?o igualdade (===) a compara??o est? certa.

Reproduce code:
---------------
//array vindo da session, unserialize($_SESSION['menu'])
Array
(
    [menu_2008311143334693] => Array
        (
            [ordenador] => 0
            [id] => 2008311143334693
            [parentId] => 2008311143334693
            [label] => Relat?rios
            [action] =>  
            [help] => 
            [imagem] => 
            [filhos] => Array
                ( ....
                    
echo strlen($menuPermissaoUser['menu_2008311143334693']['ordenador']).'<br>';
			echo gettype($menuPermissaoUser['menu_2008311143334693']['ordenador']).'<br>';
			echo $menuPermissaoUser['menu_2008311143334693']['ordenador'].'<br>';
			if($menuPermissaoUser['menu_2008311143334693']['ordenador'] == 'qualquer coisa')
				echo'IGUAL<br>';
			
			if(trim($menuPermissaoUser['menu_2008311143334693']['ordenador']) == 'qualquer coisa')
				echo 'IGUAL<br>';			
			else
				echo 'NAO IGUAL<br>';
			
			if($menuPermissaoUser['menu_2008311143334693']['ordenador'] === 'qualquer coisa')
				echo 'IGUAL<br>';			
			else
				echo 'NAO IGUAL<br>';

Expected result:
----------------
1
integer
0
NAO IGUAL
NAO IGUAL
NAO IGUAL

Actual result:
--------------
1
integer
0
IGUAL
NAO IGUAL
NAO IGUAL

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-17 18:40 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 02 00:01:30 2024 UTC