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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.