FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PHP 5.3.9 hex bug?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
PHP 5.3.9 hex bug? [message #177002] Wed, 15 February 2012 15:12 Go to next message
aaa is currently offline  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 Go to previous messageGo to next message
tony is currently offline  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 Go to previous messageGo to next message
Denis McMahon is currently offline  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 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  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 Go to previous messageGo to next message
M. Strobel is currently offline  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 Go to previous messageGo to next message
aaa is currently offline  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 Go to previous messageGo to next message
Thomas Mlynarczyk is currently offline  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)
Re: PHP 5.3.9 hex bug? [message #177018 is a reply to message #177012] Thu, 16 February 2012 13:08 Go to previous message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 16/02/2012 10:38, aaa escribió/wrote:
>> 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.

And it seems it's a valid bug: https://bugs.php.net/bug.php?id=61095



--
-- 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
--
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: session array not available in popup?
Next Topic: website management
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 10:23:44 GMT 2024

Total time taken to generate the page: 0.02430 seconds