Is the form post a string? 1. is the form post a string?
2. if it is a string type, how does one explain the following section? why can it be directly added without type conversion? This is not the case with Python.
Bob's Auto Parts - Order Result Bob's Auto Parts Order Results
Order processed.'; echo 'Order processed at '.date('H:i , jS F Y').'
'; // overcome not integer number if (is_string($tireqty) == True or is_string($oilqty) == True or is_string($sparkqty) == True) { echo "one of your input is type string.
"; echo 'Your order is as follow:
'; echo $tireqty. ' tires.
'; echo $oilqty. ' bottles of oil
'; echo $sparkqty. ' spark plugs
'; // calc total items ordered $totalqty = 0; $totalqty = $tireqty + $oilqty + $sparkqty; if ($totalqty == 0) { echo 'You did not order anything on the previous page!
'; } else { echo "Items ordered: $totalqty
"; // calc total amount $toatlamount = 0; $toatlamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE; echo 'Subtotal: $'.number_format($toatlamount,2).'
'; // calc total tax $taxrate = 0.10; $totaltaxrate = 0; $totaltaxrate = $toatlamount * 0.10; echo 'Total tax: $'.number_format($totaltaxrate,2).'
'; } } ?>
Running result:
Bob's Auto PartsOrder ResultsOrder processed at 17:33 , 15th April 2013one of your input is type string.Your order is as follow: 1 tires. 2 bottles of oil3 spark plugsItems ordered: 6 Subtotal: $132.00Total tax: $13.20
Reply to discussion (solution)
Python's string connector and arithmetic addition are both plus signs. if you use '1' + '2', python cannot understand what you mean. are you adding strings or connecting them? It can not make its own claim, so it has to perform computation strictly by type.
But the PHP string connector is a. Sign. if you use '1' + '2', it certainly understands that you want to add, not connect. Therefore, the result is 3 rather than '12 '. Even if you use '1' + 'sss', you will get the number 1.
1. it is a string type.
2. Many languages have the auto Cast function.
Hehaoha had this kind of idea when I first came into contact with weak languages, so it would be nice to get used to it...
Python is of a weak type and does not need to declare field attributes. although python is of a weak type, it does not recognize the field type by default.
What type is passed or what type is passed?