Getting result with C:\wamp64\www\.....

I am using a localhost and wampserver.

I have run the following script:

<?php $x = 10.365; var_dump($x); ?>

I am getting the following result:

C:\wamp64\www\test3.php:7:float 10.365

If any one can guide me why I am getting this result. The correct answer on the web server is: float(10.365)

Thank you.

Well, you got the correct results. Using the var_dump() function is different depending on your version of PHP.

It is clear from your results that you are using the latest PHP 7.0… Therefore, you got the correct results.

If you want to just print the value of the variable instead of dumping the internal value of the variable, just use echo $x;
Normally, when you display a floating number, you use formatting to display it in the format you wish it to show in.
Here is the PHP manual’s version of the formatting functions. See the examples below where people posted.
http://php.net/manual/en/function.number-format.php

Hope this helps!

Not sure why you think you are NOT getting the correct answer, the number and type are correct, so I don’t actually see an issue.

Thank you to both ErnieAlex and astonecipher for the response and giving the tips.

I think I must only use just echo $x ; instead of dumping the internal value. This way it would be simple and precise.

Appreciate for confirming to me that the result is correct.

All the best.

Sponsor our Newsletter | Privacy Policy | Terms of Service