|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6678 Different behaviour of arithmetic operations on Linux PHP and Windows PHP
Submitted: 2000-09-12 05:41 UTC Modified: 2004-10-19 18:29 UTC
From: info at emre dot de Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 4.0.2 OS: Windows 2000 & SuSE Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
31 - 26 = ?
Subscribe to this entry?

 [2000-09-12 05:41 UTC] info at emre dot de

/* Fuction to turn an integer into an ip address */

function int2ip($int) 
    // There are 4 bytes to handle, so let?s go for it ....
    for ($i=0 ; $i < 4 ; $i++) {
     // Let?s leave only the first 8 bits, kill the rest and assign the value to an array element
      $bytes[$i] = $int & 0xFF; 
     // Now move the remaining bits to the right and go on with the next byte ... 
      $int = $int >> 8;

    // The array containing the bits is joined to a string, the bytes separated by a dot 
    $ip = "$bytes[3].$bytes[2].$bytes[1].$bytes[0]"; 
   return ($ip); 

print int2ip(3232235648); 

  Result should be On WAMP it works fine,
  on LAMP it doesn?t.
  Maybe this one?s not bug but I?m too dump - still this "wrong" behaviour
  has been verfied on several Linux systems running Apache and PHP.
  The correct one has been verified on three Windows systems running
  Apache and PHP (latest)



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-15 11:25 UTC]
Your problem is probably due to the size of the numeric datatype (which is system dependant). The number that you're passing is actually too big (ie: over 2 billion).


PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 16 15:01:28 2024 UTC