Jump to content

when to use ob_start() and ob_flush example only.


redarrow

Recommended Posts

<?php session_start();
function add_shopping($price,$quienty,$shipping,$discount,$tax,$payments){
$total=($price*$quienty)+($shipping)-($discount);
$taxrate=($tax/100)+1;
$total=$total*$taxrate;
$monthly=$total/$payments;
$_SESSION['monthly']=$monthly;
$_SESSION['total']=$total;
$_SESSION['payments']=$payments;
return;
}
echo add_shopping('20.00','10','7.50','10%','17.50','12');
echo "Complete total ".£.number_format($_SESSION['total'],2)."\n
<br> <br> ".$_SESSION['payments']." monthly payments ".£.number_format($_SESSION['monthly'],2)."<br>";
ob_start();
echo "<br> ".$_SESSION['payments']='52'." weekly payments ".£.number_format($_SESSION['monthly']/4,2)." ";
ob_flush();
?>

 

Your all notice there the php function ob_start used on this page, and might wonder why, also there ob_flush() used at the end of the page.

 

grate stuff i say....

 

i reset the session so there no conflict to 52 without ob_start() and ob_flash never do that it change all numbers and give wrong result.

never do that it change all numbers and give wrong result

 

What does it change the numbers too? What result does it give?

 

You have a syntax error on the last two echo statements, a pound sign not wrapped in quotes.

 

Is English your primary language?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.