[ miljan9602 @ 26.06.2013. 10:43 ] @
Ovako poceo sam da radim PHP i imam jedan cd sa skriptama pomocu kojeg ucim, i ne razumem jedan deo u skriptu pa mi treba pomoc.. Code: <?php // create short variable names $tireqty = $_POST['tireqty']; $oilqty = $_POST['oilqty']; $sparkqty = $_POST['sparkqty']; $find = $_POST['find']; ?> <html> <head> <title>Bob's Auto Parts - Order Results</title> </head> <body> <h1>Bob's Auto Parts</h1> <h2>Order Results</h2> <?php echo "<p>Order processed at ".date('H:i, jS F Y')."</p>"; echo "<p>Your order is as follows: </p>"; $totalqty = 0; $totalqty = $tireqty + $oilqty + $sparkqty; echo "Items ordered: ".$totalqty."<br />"; if ($totalqty == 0) { echo "You did not order anything on the previous page!<br />"; } else { if ($tireqty > 0) { echo $tireqty." tires<br />"; } if ($oilqty > 0) { echo $oilqty." bottles of oil<br />"; } if ($sparkqty > 0) { echo $sparkqty." spark plugs<br />"; } } $totalamount = 0.00; define('TIREPRICE', 100); define('OILPRICE', 10); define('SPARKPRICE', 4); $totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE; echo "Subtotal: $".number_format($totalamount,2)."<br />"; $taxrate = 0.10; // local sales tax is 10% $totalamount = $totalamount * (1 + $taxrate); echo "Total including tax: $".number_format($totalamount,2)."<br />"; switch($find) { case 'a': echo '<p> Regular costumer.</p>'; break; case 'b': echo '<p> TV advertising. </p>'; break; case 'c': echo '<p> Phone directory. </p>'; break; case 'd': echo '<p> Word of mouth. </p>'; break; default: echo '<p> We dont know how this costumer found us. </p>'; break; } ?> </body> </html> Ne razumem ovaj deo: .number_format($totalamount,2). sta ovo znaci znam da je totalamount promenjljiva, ali sta je ovo number_format, i ne razumem zasto ova 2 stoji iza zareza, koja je njena funkcija ? I jos ovo: $totalamount = $totalamount * (1 + $taxrate); Zasto se nalazi 1+ ispred $taxrate ? Mozda ovo vama izgleda glupo il smesno, al poceo sam sa phpom juce pa mi ovo jos nije jasno, hvala unapred svima |