Wy in Php 01 is greater than 1 ?

This is a discussion on Wy in Php 01 is greater than 1 ? within the PHP Language forums, part of the PHP Programming Forums category; Wy in Php 01 is greater than 1 ?...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-12-2007
wbrowse@gmail.com
 
Posts: n/a
Default Wy in Php 01 is greater than 1 ?

Wy in Php 01 is greater than 1 ?

Reply With Quote
  #2 (permalink)  
Old 05-12-2007
Schraalhans Keukenmeester
 
Posts: n/a
Default Re: Wy in Php 01 is greater than 1 ?

At Sat, 12 May 2007 06:28:04 -0700, wbrowse let his monkeys type:

> Wy in Php 01 is greater than 1 ?


It's not, not even when comparing these as strings.

echo (01 > 1) ? 'bigger' : 'equal or smaller';
// outputs: equal or smaller

echo ('01' > '1') ? 'bigger' : 'equal or smaller';
// outputs: equal or smaller

Show the code you used to get the result you did if you want more help...

HTH
Sh.

Reply With Quote
  #3 (permalink)  
Old 05-12-2007
Andy Hassall
 
Posts: n/a
Default Re: Wy in Php 01 is greater than 1 ?

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?
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Reply With Quote
  #4 (permalink)  
Old 05-12-2007
Andy Hassall
 
Posts: n/a
Default Re: Wy in Php 01 is greater than 1 ?

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
Reply With Quote
  #5 (permalink)  
Old 05-12-2007
Jerry Stuckle
 
Posts: n/a
Default Re: Wy in Php 01 is greater than 1 ?

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.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
  #6 (permalink)  
Old 05-12-2007
Jerry Stuckle
 
Posts: n/a
Default Re: Wy in Php 01 is greater than 1 ?

Andy Hassall wrote:
> 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.


Of course you're right... I should think more before replying... :-)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
  #7 (permalink)  
Old 05-28-2007
wbrowse
 
Posts: n/a
Default Re: Wy in Php 01 is greater than 1 ?

First, sorry for telling you so little with this issue and leaving it
for so long without much care from me...

Below you can find the script that made feel confused (I am an early
Php beginner but I have to stop as for professional needs I need to
concentrate my free time on learning VBA...) :

Test it with 01 as I can't test it on my current configuration(see
below why).

===========start==========


<html>
<head>
</head>

<body>



<?php

//lancer recherche $_POST['submit'] dans fichier aide PHP

if (!$_POST['submit'])

{

?>

<form action="<?=$_SERVER['PHP_SELF']?>" method="post">

Saisissez un nombre : <input name="nombre" size="2">

<input type="submit" name="submit" value="Valider">

</form>

<?php

}

else

{

$nombre = $_POST['nombre'];

if ($nombre < 0)

{echo 'Vous avez saissi un nombre -';
}

elseif ($nombre > 0)

{echo 'Vous avez saissi +';
}

else

{echo 'Vous avez saissi un nombre neutre';
}

}

?>

</body>


</html>

===========end==========


As I changed computer, I had to reinstall php, apache and I wanted to
test this script again but I had this message:

You don't have permission to access /arch/< on this server.

The other script I run all are working (with forms...) under XP.

It's no big issue for me right now as it's confusing learning 2
languages at the same time... so I am concentrating on vba and leaving
Php for later...


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:27 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0