PHP 5.3.9 hex bug? [message #177002] |
Wed, 15 February 2012 15:12 |
aaa
Messages: 4 Registered: February 2012
Karma: 0
|
Junior Member |
|
|
Hello,
Why is this:
fseek($f, 0x0000+2, SEEK_SET);
giving same result as:
fseek($f, 4, SEEK_SET);
and not same result as:
fseek($f, 0000+2, SEEK_SET);
or
fseek($f, 2, SEEK_SET);
?
What is wrong with the hex notation?
--
A
|
|
|
Re: PHP 5.3.9 hex bug? [message #177003 is a reply to message #177002] |
Wed, 15 February 2012 16:36 |
tony
Messages: 19 Registered: December 2010
Karma: 0
|
Junior Member |
|
|
In article <jhgi0p$r76$1(at)speranza(dot)aioe(dot)org>, aaa <aaa(at)aaaaaaaaaaa(dot)com> wrote:
> Hello,
> Why is this:
> fseek($f, 0x0000+2, SEEK_SET);
> giving same result as:
> fseek($f, 4, SEEK_SET);
> and not same result as:
> fseek($f, 0000+2, SEEK_SET);
> or
> fseek($f, 2, SEEK_SET);
> ?
> What is wrong with the hex notation?
What does it give you if you just print the expressions instead?
Cheers
Tony
--
Tony Mountifield
Work: tony(at)softins(dot)co(dot)uk - http://www.softins.co.uk
Play: tony(at)mountifield(dot)org - http://tony.mountifield.org
|
|
|
Re: PHP 5.3.9 hex bug? [message #177004 is a reply to message #177002] |
Wed, 15 February 2012 16:48 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On Wed, 15 Feb 2012 16:12:43 +0100, aaa wrote:
> Hello,
> Why is this:
> fseek($f, 0x0000+2, SEEK_SET);
> giving same result as:
> fseek($f, 4, SEEK_SET);
> and not same result as:
> fseek($f, 0000+2, SEEK_SET);
> or
> fseek($f, 2, SEEK_SET);
> ?
> What is wrong with the hex notation?
from "http://uk.php.net/manual/en/function.fseek.php" we find that "Upon
success, returns 0; otherwise, returns -1."
Perhaps the problem is actually with "what happens next" when taken in
the context of "what the file contains".
Rgds
Denis McMahon
|
|
|
Re: PHP 5.3.9 hex bug? [message #177006 is a reply to message #177002] |
Wed, 15 February 2012 17:48 |
alvaro.NOSPAMTHANX
Messages: 277 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
El 15/02/2012 16:12, aaa escribió/wrote:
> Why is this:
> fseek($f, 0x0000+2, SEEK_SET);
> giving same result as:
> fseek($f, 4, SEEK_SET);
> and not same result as:
> fseek($f, 0000+2, SEEK_SET);
> or
> fseek($f, 2, SEEK_SET);
> ?
> What is wrong with the hex notation?
It's really funny:
var_dump(0x0 + 2, 0x0+ 2, 0x0+2, 0x0 +2);
.... prints:
int(2)
int(2)
int(4)
int(4)
No idea of what's going on but it only seems to affect hexadecimal zero
so at least there's an obvious workaround.
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
|
|
|
Re: PHP 5.3.9 hex bug? [message #177008 is a reply to message #177002] |
Wed, 15 February 2012 19:00 |
M. Strobel
Messages: 386 Registered: December 2011
Karma: 0
|
Senior Member |
|
|
Am 15.02.2012 16:12, schrieb aaa:
> Hello,
> Why is this:
> fseek($f, 0x0000+2, SEEK_SET);
> giving same result as:
> fseek($f, 4, SEEK_SET);
> and not same result as:
> fseek($f, 0000+2, SEEK_SET);
> or
> fseek($f, 2, SEEK_SET);
> ?
> What is wrong with the hex notation?
>
About hex numbers and strings of hex numbers see thread
"Implied cast differs from explicit cast".
It looks like PHP is not very consistent there.
/Str.
|
|
|
Re: PHP 5.3.9 hex bug? [message #177012 is a reply to message #177006] |
Thu, 16 February 2012 09:38 |
aaa
Messages: 4 Registered: February 2012
Karma: 0
|
Junior Member |
|
|
> It's really funny:
>
> var_dump(0x0 + 2, 0x0+ 2, 0x0+2, 0x0 +2);
>
> ... prints:
>
> int(2)
> int(2)
> int(4)
> int(4)
>
> No idea of what's going on but it only seems to affect hexadecimal zero so
> at least there's an obvious workaround.
Yeah. I already reported that bug to PHP guys, so perhaps 5.2.11 will have
it fixed.
I spent like 5 hours trying to figure out what's wrong with my code ;/
--
A
|
|
|
Re: PHP 5.3.9 hex bug? [message #177013 is a reply to message #177006] |
Thu, 16 February 2012 11:37 |
Thomas Mlynarczyk
Messages: 131 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
Álvaro G. Vicario schrieb:
> It's really funny:
>
> var_dump(0x0 + 2, 0x0+ 2, 0x0+2, 0x0 +2);
>
> ... prints:
>
> int(2)
> int(2)
> int(4)
> int(4)
This bug does not seem to occur with PHP 5.2 (Tested with 5.2.12). So it
was probably introduced with PHP 5.3 (and is still present in 5.4.0alpha3).
Greetings,
Thomas
--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
|
|
|
|