You are here: Re: Wy in Php 01 is greater than 1 ? « PHP Programming Language « IT news, forums, messages
Re: Wy in Php 01 is greater than 1 ?

Posted by Andy Hassall on 05/12/07 18:47

On Sat, 12 May 2007 14:26:19 -0500, Jerry Stuckle <jstucklex@attglobal.net>
wrote:

>Andy Hassall wrote:
>> On 12 May 2007 06:28:04 -0700, wbrowse@gmail.com wrote:
>>
>>> Wy in Php 01 is greater than 1 ?
>>
>> It isn't. But perhaps you meant something else?
>
>Maybe he mean '01' is bigger than ' 1'. It would be.

But even then:

$ php -r "var_dump('01' > ' 1');"
bool(false)

$ php -r "var_dump('01' < ' 1');"
bool(false)

You have to get down to strcmp() to start showing up a difference, which
strays even further from what the OP posted.

$ cat test.php
<?php
$a = array('01', ' 1', '1');
sort($a);
print join("\n", $a);
?>

$ php test.php
1
1
01

So, back to the OP to clarify what he's on about... but certainly the sort
results above are a reasonable cause for confusion unless you get your head
around exactly when PHP does implicit type conversions.
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация