All tags/Diff
Side by side
Two versions of a function next to each other, line numbers on both sides and the changed words marked.
<?php
$before = <<<'TEXT'
function total ( $rows ) {
$sum = 0;
foreach ( $rows as $row )
$sum += $row ['price'];
return $sum;
}
TEXT;
$after = <<<'TEXT'
function total ( $rows, $tax = 0.21 ) {
$sum = 0;
foreach ( $rows as $row )
$sum += $row ['price'] * $row ['quantity'];
return round ( $sum * ( 1 + $tax ), 2 );
}
TEXT;
?>
{diff $before, $after, side, from='total.php - before', to='total.php - after'}
| total.php - before | total.php - after | ||
|---|---|---|---|
| 1 | function total ( $rows ) { | 1 | function total ( $rows, $tax = 0.21 ) { |
| 2 | 2 | ||
| 3 | $sum = 0; | 3 | $sum = 0; |
| 4 | 4 | ||
| 5 | foreach ( $rows as $row ) | 5 | foreach ( $rows as $row ) |
| 6 | $sum += $row ['price']; | 6 | $sum += $row ['price'] * $row ['quantity']; |
| 7 | 7 | ||
| 8 | return $sum; | 8 | return round ( $sum * ( 1 + $tax ), 2 ); |
| 9 | 9 | ||
| 10 | } | 10 | } |