php-windows Digest 19 Oct 2005 14:44:37 -0000 Issue 2799
Topics (messages 26417 through 26418):
Re: Is this a PHP bug?
26417 by: graeme_foster
Strange CGI Timeout, only when using IE
26418 by: dan conner
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
The language designers needed to decide to convert mixed variables from
one type to another before the comparison. They chose to convert the
string to a number because that is what many people will want
automatically, remember the data will typically arrive as a string from
the web page and for it to be automatically converted to a number is
helpful (although I would recommend the use of the is_numeric() and
is_int() functions). So if the string doesn't contain a valid number,
for example the string "Hello" then it needs to be set to a value, some
languages (C / C++) will leave it uninitialised, so it could have any
value. PHP initialises to the null value, or zero. Whilst it appears to
behave inconsistently there is both logic and reason to way it works.
Try out the following tests:
0 == "Hello"
1 == "Hello"
1 == "1"
2 == "1"
2 == "2Go"
2 == "Way2Go"
Understanding the above will help you to understand how PHP does the
conversation from strings to numbers.
all the best,
graeme.
(Sorry forgot to also send this to the list...)
Ross Honniball wrote:
I'm yet to be convinced it isn't a bug. I suspect it is a bug that has
been around so long that they can't afford to fix it or it may break
many applications that for various peculiar reasons rely on it to
behave as it does for their code to work.
For those who have tried to defend its behaviour, this is my logic.
1. The == operator means, by definition, "don't worry about variable
'type', just compare the values"
(This is probably the single thing I love about PHP more than
anything else)
2. If the numeric variable $x is given ANY other numeric value other
than zero, the logic behaves correctly as you read it
So it is irrational for program logic to vary between a zero value
and, for aguments sake, a numeric value of 42.
Regarding specifically TG's explanation below, I believe he is wrong.
If you compare a numeric type and a string type using ==, PHP should
convert the number to a string and compare the two from there.
Anyway, not expecting any answers to this, just a point of note and a
strange quirk to keep at the back of your head when consciously
comparing numeric / string variables.
Ross
[EMAIL PROTECTED] wrote:
It's because PHP is trying to convert different var types into a
common var type and then compare them when you use ==. === means
compare value AND type so that's why it fails.
Your string, 'Some kind of string' is getting converted down to the
lowest common denominator, an int. Since there are no numbers in the
string to grab onto, it gets converted to nothing, an int value of zero.
If you had $x = "0" or if $y had contained numbers at all, it
wouldn't have passed.
But this is why when you use $x.'' it works properly because now you
have "0<empty string>", it's been converted to a string value "0".
Good catch on that though, shows good methodical debugging :)
So in the future, either use === or be extra aware of your variable
types and make sure you're comparing properly.
Good luck!
-TG
= = = Original message = = =
$x = 0; // Numeric zero
$y = 'Some kind of string';
if ($x == $y) echo 'they equal using ==';
if ($x === $y) echo 'they equal using ===';
The above will echo 'they equal using =='.
The values don't look very equal to me.
Can anyone explain the logic behind this?
I'm heading home now but look forward to your explanations tomorrow.
PS
Incidently, to 'fix' it so it behaves as it should, you can code:
if ($x.'' == $y.'') echo 'this will not print and all is good.';
Regards .. Ross
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
--- End Message ---
--- Begin Message ---
by some internet news archives, there was a post on this list that describes
what I am seeing:
http://www.issociate.de/board/post/166611/Strange_CGI_Timeout.html
we have a windows 2000 server with PHP 5.0.3 installed. a website within IIS
has .php extensions mapped to php-cgi.exe.
within that site there is an affiliate program that we have downloaded.
within that program, as you would expect, are several forms to save
information, and one to upload images. *all* of these forms work without
problems when using Firefox. *most* of these forms work fine with Internet
Explorer (6.0), like the login form allows a user to log in to the system.
however, when using Internet Explorer, some of the forms cause a CGI
Timeout. it seems to be related to the size of the post of the form, and
only happens when the method on the form is POST. it seems related to the
size because it only happens on forms that either have a file upload, or a
textarea that is being posted.
the problem has to be something to do with the cgi executable and its
interaction with IIS, because the php in the page itself is not being
executed at all. if you place some simple code to echo and exit at the top
of the php file, it does not even reach that.
I think plenty of people have seen this problem before. I've heard that
deleting an entry from the IIS MetaBase fixes the problem. does anybody have
any ideas on what I should be looking for to fix the problem?
thanks!
Dan
--- End Message ---