hi all, i would like to ask what is the solution. using the code below: <html> <head> <?php $test = "http://www.consiariat.us/xxx/ip/2.90.208.84.xxx"; $t = intval((file_get_contents($test) + (2 * 60)) * 1000); ?> <?php echo $t; ?><br> <?php echo file_get_contents($test);?> </body> </html> PHP: gives different results using different hosting sites. the code is used in heliohost.org: http://simple.heliohost.org/faucet/test.php Result: 1501322878000 1501322758 but when code is used in atspace.com http://consiariat.us/02faucet/test.php Result: -1915675600 1501322758 what is seems to be the problem. why at atspace it is giving negative value? thanks.
I had a play around and couldn't get that negative number. What happens if you try this: <html> <head> <?php $test = "http://www.consiariat.us/xxx/ip/2.90.208.84.xxx"; $contents = file_get_contents($test); $t = intval($contents + (2 * 60)) * 1000; $u = intval($contents) + (2 * 60 * 1000); $v = (intval($contents) + (2 * 60)) * 1000; ?> <?php echo $t; ?><br> <?php echo $u; ?><br> <?php echo $v; ?><br> <?php echo "|{$contents}|<br/>";?> <?php echo intval($contents);?> </body> </html> PHP: You don't have to break your code down but when it's playing up it can help the debugging process. My variations have the brackets around the numbers at the end differently - was just seeing what different answers I get. I suspect the intval only needs to be around "contents" since the 2, 60 and 1000 are known to be integers, unless they're also going to be variables once you get past this problem. I've put the pipes around the echo of $contents so that you can see if the other host is finding hidden characters that it's parsing differently.
hello, thanks for your quick reply. i have used your code. here are the results link: http://consiariat.us/02faucet/test.php Results: 1.501322878E+12 1501442758 1.501322878E+12 |1501322758| 1501322758 link: http://simple.heliohost.org/faucet/test.php Results: 1501322878000 1501442758 1501322878000 |1501322758| 1501322758 does it have to do with hosting settings?
hi. may i know where to find if i am on 32 bit or windows? i am just on basic hosting. this is the only details i know of my hosting plan: • Unlimited Disk Space • Unlimited Monthly Traffic • 2 Domains Hosting • 5 Subdomains • Free DNS Server • PHP, Perl/CGI-BIN • 2 MySQL Databases • FTP Access • Unlimited POP3/IMAP E-mails • Instant Account Setup • Web-based File Manager • Easy-to-use Control Panel • Reliable RAID Backups • GRID Hosting Platform • Super Fast Servers • Reliable Data Center • Ultra Fast Network • 99.8% Uptime Guarantee • 24x7 Network Monitoring • 24x7 Ticket Support • Fully Upgradeable
So it looks like both servers are giving the same results - just displaying the numbers differently. as for the hosting - there are websites that can look that up for you
thanks. i have issued a support ticket from atspace but they haven't replied yet. the files i am using are working fine in free hosting which is heliohost.org and have issues when used in paid hosting in atspace.com.
For the negative number, I'm guessing this as the reason: http://php.net/manual/en/language.types.integer.php: So you may be interested to perform a little test, as follows: $int1 = PHP_INT_MAX; $int2 = PHP_INT_MAX+1; //overflowN echo 'int1 = ', $int1, PHP_EOL; echo 'int2 = ', $int2, PHP_EOL, PHP_EOL; //overflown echo 'inval1 = ', intval($int1), PHP_EOL; echo 'intval2 = ', intval($int2), PHP_EOL; //overflown PHP:
thanks for the reply. below are the results. atspace.com result: int1 = 2147483647 int2 = 2147483648 inval1 = 2147483647 intval2 = -2147483648 heliohost.org result: int1 = 9223372036854775807 int2 = 9.22337203685E+18 inval1 = 9223372036854775807 intval2 = -9223372036854775808
Which means that atspace is running on 32bit... for what reason, I have NO idea. There is absolutely no reason to run ANYTHING on 32 bit these days. Even the lowliest laptop is running on 64bit.
thanks all for your response. maybe just have to remodel some of the codes. gonna use sarahk's suggestion.
Just take note that if any of your numbers exceed the limit for 32bit, it will return broken / weird results if run on such a platform. No matter how you format or try to work around it - if you use bigger numbers, it will break. Best way to fix it is to make sure you run on 64bit systems.