Test eshop - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Test eshop.php
- <?php
- $tndl = [500, 1234567890];
- $tndc = [0.0857, 0.0932];
- $tnnl = [100, 300, 1234567890];
- $tnnc = [0.0432, 0.0489, 0.05321];
- $katDay = 890;
- $katNight = 195;
- $i = 0;
- $costEstNight = 0;
- while ($i < 6) {
- echo '<br /> <br />$i counter is:'.$i.' <br /> ';
- echo '$katNight: '.$katNight.' <br /> ';
- echo 'tnnl: '.$tnnl[$i].' <br /> ';
- echo 'tnnc: '.$tnnc[$i].' <br /> ';
- if ($i == 0 && $katNight >= $tnnl[$i]) {
- $costEstNight = $costEstNight + ($tnnl[$i] * $tnnc[$i]);
- echo '0:'.$costEstNight.' <br /> ';
- $diff = $tnnl[$i] - $tnnl[$i-1];
- echo 'current: '.$tnnl[$i].' before: '.$tnnl[$i-1].' diff: '.$diff.' <br /> ';
- $katNight = $katNight - $tnnl[$i];
- // if it is not the last tier which has the Xlarge value of 1234567890.
- } elseif ($i != 0 and ($tnnl[$i]) != 1234567890) {
- // The tier limit minus the tier limit of the previous tier.
- // e.g. tier1_limit is 1000 and tier2_limit is 2000 -> consumption is 2000 kWh, 1000 from tier1 and 1000 from tier2.
- $costEstNight = $costEstNight + (($tnnl[$i] - $tnnl[$i-1]) * $tnnc[$i]);
- $diff = $tnnl[$i] - $tnnl[$i-1];
- echo 'current: '.$tnnl[$i].' before: '.$tnnl[$i-1].' diff: '.$diff.' <br /> ';
- echo '1:'.(($tnnl[$i] - $tnnl[$i-1]) * $tnnc[$i]).' <br /> ';
- $katNight = $katNight - ($tnnl[$i] - $tnnl[$i-1]);
- } else {
- // Adds to the estimated cost the number of the remaining kWh multiplied by the cost of the kWh of this last tier.
- $costEstNight = $costEstNight + ($katNight * $tnnc[$i]);
- $diff = $tnnl[$i] - $tnnl[$i-1];
- echo 'current: '.$tnnl[$i].' before: '.$tnnl[$i-1].' diff: '.$diff.' <br /> ';
- echo '2:'.$costEstNight.' <br /> ';
- break;
- }
- $i = $i + 1;
- }
- $attrPagio = 4.40;
- // Total cost estimates calculation
- $costEst = $attrPagio + (500*0.0857+390*0.0932) + $costEstNight;
- $costEstFormatted = number_format($costEst, 2, ',', '.');
- $costEstFormattedYearly = $costEst*12;
- echo 'test <br />';
- echo $costEst;
- //92.5635
File Description
- Test eshop
- PHP Code
- 25 Sep-2020
- 2.06 Kb
You can Share it:
Latest PHP Pastes