473,327 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Wy in Php 01 is greater than 1 ?

Wy in Php 01 is greater than 1 ?

May 12 '07 #1
6 1490
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.

May 12 '07 #2
On 12 May 2007 06:28:04 -0700, wb*****@gmail.com wrote:
>Wy in Php 01 is greater than 1 ?
It isn't. But perhaps you meant something else?
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
May 12 '07 #3
Andy Hassall wrote:
On 12 May 2007 06:28:04 -0700, wb*****@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.
js*******@attglobal.net
==================
May 12 '07 #4
On Sat, 12 May 2007 14:26:19 -0500, Jerry Stuckle <js*******@attglobal.net>
wrote:
>Andy Hassall wrote:
>On 12 May 2007 06:28:04 -0700, wb*****@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 :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
May 12 '07 #5
Andy Hassall wrote:
On Sat, 12 May 2007 14:26:19 -0500, Jerry Stuckle <js*******@attglobal.net>
wrote:
>Andy Hassall wrote:
>>On 12 May 2007 06:28:04 -0700, wb*****@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.
js*******@attglobal.net
==================
May 12 '07 #6
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...
May 28 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Martin | last post by:
I am trying to write code that selects a random number in the range 0 to n, where n can be substantially greater than the RAND_MAX on my system which is 32767. I am using VC++ 2003 FWIW. As you...
3
by: Massimiliano Alberti | last post by:
Can someone check this? If it's OK, you can use however you want... :-) It should search for an element in an array and, if it can't find it, return the next element. key is what you are...
2
by: John Mark Howell | last post by:
BlankDoes anyone know how to overload the greater than (>) operator? I know that it is probably not in accordance to the framework design patterns, but it would make my code much cleaner. -- ...
7
by: BobRoyAce | last post by:
Let's say I have a text box on a page in which a user is to enter a monetary amount and that I want to ensure that the user enters a value greater than or equal to a certain value that will be...
0
by: Michael Mallete | last post by:
good day everyone! i am using postgresql-8.0beta2-dev3 windows port, with postgis-0.9 add-on. anyway, while trying to insert a table using shp2pgsql, i get this error: psql:temp.sql:38:...
2
by: James | last post by:
i m looking for suggestions in this news groups what is the best way to delete files greater than x days. scenario / conditions a) d:\dir\queue\*.* files to be deleted. b) no-touch solutions ...
2
by: Stevie | last post by:
Hello I'm trying to work out the regular expression for carrying out a simple 'greater than' comparison. I have a directory with files such as asd345.log, asd346.log, asd347.log and so on.
13
by: HockeyFan | last post by:
I'm not sure how to exactly ask this, but expect that it's a Javascript solution. However, I'll ask the question and maybe someone can point me to some existing code that will do what I need. I...
4
by: minsumoosane | last post by:
Hello, Can anyone help me write a php program that have two numbers as input and then choose the greater number of the two.For example, 2 and 7 and choosing 7 as the greater number Thank you so...
1
by: ciojr | last post by:
how do i write a sql (ORACLE) statement for where the first word in the name field is greater than 17 chars? if i do this SELECT businessname FROM tablename WHERE LEN(businessname) 17; it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.