Asked  8 Months ago    Answers:  5   Viewed   27 times

Could anyone please tell me why this happens,

$a  = 0.000022

echo $a // 2.2E-5

What I want to see is 0.000022 not 2.2E-5



The exponential form is the internal one use by every (?) programming language (at least CPUs "sees" floats this way). Use sprintf() to format the output

echo sprintf('%f', $a);
// or (if you want to limit the number of fractional digits to lets say 6
echo sprintf('%.6f', $a);

See Manual: sprintf() about more information about the format parameter.

Wednesday, March 31, 2021
answered 8 Months ago

You can also use printf() functions to pad the integer :

Something like (codepad):


function pad($n) {
    $n = explode('.', (string)$n);

    if (2 === count($n)) {
        return sprintf("%02d.%dn", $n[0], $n[1]);    

    return sprintf("%02dn", $n[0]);    

foreach (array(2, 22, 222, 2., 2.11) as $num) {
    echo pad($num);

// returns 02, 22, 222, 02, 02.11
Wednesday, March 31, 2021
answered 8 Months ago

You should point to your vendor/autoload.php at Settings | PHP | PHPUnit when using PHPUnit via Composer.

This blog post has all the details (with pictures) to successfully configure IDE for such scenario:

Related usability ticket:

P.S. The WI-18388 ticket is already fixed in v8.0

Wednesday, March 31, 2021
answered 8 Months ago

On Mac OS X environment variables available in Terminal and for the normal applications can be different, check the related question for the solution how to make them similar.

Note that this solution will not work on Mountain Lion (10.8).

Saturday, May 29, 2021
answered 5 Months ago

printf and friends will do this:

$awb = 2.01421700079E+14;
$str = sprintf("%d", $awb);


string(15) "201421700079000"

There obviously isn't enough information in your original number to get any more precision than that.

Saturday, May 29, 2021
answered 5 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :