Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

269
Visualizações
In XAMPP numbers act different than real servers?

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 AT WINDOWS 10 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.

For those of you using XAMPP in windows localhost, do you see the same problem?

What might be the cause? how to fix it????

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Since you are using XAMPP, it only has 32bit for Windows. This in turn means that number may not exceed the range of [−2 147 483 648, 2 147 483 647]. On Linux and iOS I believe there's 64bit version for XAMPP.

So its very likely that your hosts use a 64 bit version, which would allow usage of much higer numbers as integers. What you're seeing is overflowing, the limit is reached and you "start again" from the bottom range.

Since PHP is loosely typed, a string and integer can be compared with the same value, eg

"10" == 10 // true
"11" == 10 // false
"10" === 10 // false because of strict comparison

So it might be a solution to work with strings instead of integers (because there's no limitation in the length of a string).


From the release announcement of PHP7, its announced that from PHP7 onwards, there will be consistent support for 64bit. So if the OS running it, and the engine is 64bit with PHP7 or higher, you will have full support for 64bit (which in turn allows you to use higher integer values).

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda