In XAMPP numbers act different than real servers?

Problems with the Windows version of XAMPP, questions, comments, and anything related.

In XAMPP numbers act different than real servers?

Postby ozkantarik » 28. April 2017 12:26

I noticed an error happening only with XAMPP.

I tried with 4 other live hosting accounts (including AWS, hostgator and 2 others), they all act the same upon numbers but not XAMPP. Here is what happens when running the same echo on real servers and XAMPP:

/* ALL SERVERS */
$testid = 5039307356925138;
echo (int)$testid;// 5039307356925138
echo $testid;// 5039307356925138

/* XAMPP (32bit) AT WINDOWS 10 64 bit LOCALHOST*/
$testid = 5039307356925138;
echo (int)$testid;// 753691858
echo $testid;// 5.03930735692514E+15
What does this mean and why!?

After working for hours in the issue, checking every forum post,

I increased precision in php.ini and restarted apache:

precision=20 (note that all live servers are only 12!)

Now it is:

/* XAMPP */
$testid = 5039307356925138;
echo (int)$testid;// 753691858
echo $testid;// 5039307356925138
As you may already guess it is still not a solution and scripts do not run properly because XAMPP treats 5039307356925138 as 753691858 ?!?

Furthermore, increasing precision too much caused problems like 3.250000000001% or something where other numbers are used.
I tried re-installing XAMPP with new version and tried this on another computer but all are the same.

I know my operating system is 64 bit and XAMPP is 32 bit (because XAMPP doesn't have 64 bit version for windows)
And I'm using SSL (https) on localhost so I need to use XAMPP.

if I use (float) instead of (int) it works but I need to increase precision as well.
Increasing precision breaks other side of the script and I'm sending the ID to API they validate the integer.

What might be the cause? how to fix it????
ozkantarik
 
Posts: 3
Joined: 28. April 2017 10:50
XAMPP version: 3.2.2
Operating System: Windows 10 64 Bit

Re: In XAMPP numbers act different than real servers?

Postby gsmith » 30. April 2017 05:30

First and foremost, Xampp is simply a bundle of software from various places.
Apache is from http://www.apachelounge.com
PHP is from windows.php.net
etc, etc.

Here you are dealing with php, and I can tell that it's 5.x. Using your script as posted;

d:\tmp>php -v
PHP 5.6.29 (cli) (built: Dec 8 2016 12:21:50)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

d:\tmp>php testid.php
753691858
5.0393073569251E+15

d:\tmp>php -v
PHP 7.0.18 (cli) (built: Apr 11 2017 16:17:47) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

d:\tmp>php testid.php
5039307356925138
5039307356925138

Both have a precision of 14;

I'd wager all those live hosting accounts are running php7 as well.
gsmith
 
Posts: 278
Joined: 29. November 2013 18:04
Location: San Diego
XAMPP version: 0.0.0
Operating System: Win 10/2012R VS 14,15,16

Re: In XAMPP numbers act different than real servers?

Postby ozkantarik » 30. April 2017 11:23

Thank you very much for your answer!
Seems like you made it, right??
How did you do that, will you please explain me what to do in steps?
Which versions to install, where, how please???
I just need it to work, don't care whatever the version.

I installed the XAMPP with PHP7 bundle, it didn't work.
I wonder how did you make it...
ozkantarik
 
Posts: 3
Joined: 28. April 2017 10:50
XAMPP version: 3.2.2
Operating System: Windows 10 64 Bit

Re: In XAMPP numbers act different than real servers?

Postby Nobbie » 30. April 2017 12:19

ozkantarik wrote:Which versions to install, where, how please???


As gsmith already explained, Xampp is only a collection of different tools (some might call it a "distribution"). Instead of using Xampp, you may of course proceed to the different sites (i.e. http://httpd.apache.org/, http://www.php.net, https://mariadb.com/) and download Windows binaries and install them on yourself. Apache does not provide binaries, but you will find Links to distributors, which provide binaries. You will also find some readmes, how to adapt Apache/PHP/MariaDB in order to work together.

Of course it is not as easy to install as Xampp, but therefore you are free to build your own combination of tools as you want.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: In XAMPP numbers act different than real servers?

Postby ozkantarik » 30. April 2017 12:31

After I read gsmith's answer, I downloaded PHP7 64 bit from windows.php.net
Put the contents of the zip in the XAMPP directory.
Copied the php.ini from previous 32 bit PHP 7 by XAMPP.
But apache is unable to start this way?

If I restore original XAMPP PHP 7 32 bit, it works.
When I switch the php to my downloaded 64 bit PHP7, apache won't start.
How do I get apache start this way?
ozkantarik
 
Posts: 3
Joined: 28. April 2017 10:50
XAMPP version: 3.2.2
Operating System: Windows 10 64 Bit

Re: In XAMPP numbers act different than real servers?

Postby Nobbie » 30. April 2017 16:01

ozkantarik wrote:After I read gsmith's answer, I downloaded PHP7 64 bit from windows.php.net
Put the contents of the zip in the XAMPP directory.
Copied the php.ini from previous 32 bit PHP 7 by XAMPP.
But apache is unable to start this way?


That does not work.

ozkantarik wrote:If I restore original XAMPP PHP 7 32 bit, it works.
When I switch the php to my downloaded 64 bit PHP7, apache won't start.
How do I get apache start this way?


You cannot simply replace PHP from Xampp by any 64bit PHP installation, that requires some sophisticated knowledge. I am sorry, but that exceeds by far what i can do for you, i cannot write a huge tutorial how to install Apache/PHP etc., you have to go that way alone. Either use Xampp out of the box, or go for videos and tutorial and try to learn about Apache/PHP configuration. A forum cannot replace knowledge.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 110 guests