Re: HTML_progress problem with linux
| From: | Laurent Laville | Date: | Tue, 25 Nov 2003 19:33:53 +0000 |
| Subject: | Re: HTML_progress problem with linux | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-23872@lists.php.net to get a copy of this message | ||
> Hi,
>
> There is a problem in the way the percantages are handled.
>
> Under windows everything works fine but under linux i get the following
> in HTML_Progress_DM::getPercentComplete() if i do a var_dump
>
> percent 0,06 00 %
> percent 0,06 0 percent 0,06 00 %
> percent 0,06 0 percent 0,12 00 %
> percent 0,12 0 percent 0,18 00 %
> percent 0,18 0 percent 0,24 00 %
> percent 0,24 0 percent 0,30 00 %
> percent 0,30 0 percent 0,36 00 %
> percent 0,36 0 percent 1,00 1100 %
> percent 1,00 1
>
> when under windows i obtain
>
> percent 0.06 0.06
> percent 0.06 0.06
> percent 0.12 0.12
> percent 0.18 0.18
> percent 0.24 0.24
> percent 0.30 0.3
> percent 0.36 0.36
> percent 1.00 1
>
>
> I cannot pinpoint it but there is something there.
>
Hello Arnaud,
I don't understand how you 've obtained such result ;
Could you send me the source code and tell me what version of PHP
you're running.
As you can see, i've used a user tips found on
for english version at :
http://www.php.net/manual/en/function.floatval.php
for french (Arnaud) at :
http://fr3.php.net/manual/fr/function.floatval.php
in the HTML_Progress_DM::getPercentComplete() method
function getPercentComplete()
{
$percent = sprintf("%01.2f",
( ($this->getValue() - $this->getMinimum()) /
$this->getMaximum() )
);
if (function_exists('floatval')) {
return floatval($percent); // use for PHP 4.2+
} else {
return (float)$percent; // use for PHP 4.1.x
}
}
Laurent