views:

322

answers:

2

The problem is the following: We are creating an instance of a class testObject and fill a var with a double.

A class TestExcel extends from PhpExcel and when submitting the object testObject into the constructor we get a scientific notation of the var when we do a var_dump.

Can anyone help us out. My colleagues and I don't understand how it is possible that the content of an instance can be changed by extending the phpExcel class.

When we don't do the extension, the var_dump returns the correct notation. -- 200000 When doing the extension we get the scientific notation -- 2.0E+5

// instance of the testObject

$number = new testObject();
$number->setNumber((double)200000);

// contruct testExcelClass
$excel = new TestExcel($number);


// Class TestObject      
class testObject {

      private $number;

      public function setNumber($number){
          $this->number = $number;
      }

      public function getNumber(){
          return $this->number;
      }

}

// class test excell extends from phpexcel (http://www.codeplex.com/PHPExcel) 
class TestExcel extends PHPExcel  {

    private $number;

    public function __construct($number){
      parent::__construct();

      $this->number = $number;
      print_r($this->number); exit();

    }

}
A: 

you should probably set formatting of the cell to have the desired number format. i am not sure about the exact function, check the docs.

dusoft
A: 

it seemed to be a problem in PHP 5.2.6 that displayed the wrong notation.

php 5.2.8 solved this bug.

Kennethvr