PHP Percolate! Season 6 (19 Chapters)

Student: Jim Merrikin

script 1.10 - quotes.php

OUTPUT:

Using double quotation marks:

You are purchasing 30 widget(s) at a cost of 119.95 each. With tax, the total comes to $3,778.43

Using single quotation marks:

You are purchasing $quantity widget(s) at a cost of \$$price each. With tax, the total comes to \$$total

\n

CODE:

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>J. Merrikin - 1.10 Quotes</title>
		<link rel="stylesheet" type="text/css" href="../common.css" />
	</head>
	<body>
		<!-- Script 1.10 - quotes.php -->
		<?php
			//set the variables
			$quantity = 30; //Buying 30 widgets
			$price = 119.95;
			$taxrate = .05; //5% sales tax

			//calculate the total
			$total = $quantity * $price;
			$total = $total + ($total * $taxrate);
			  //calculate and add the tax

			//format the total
			$total = number_format($total, 2);

			//print the results using double quotation marks
			echo "<h3>Using double quotation
			marks:</h3>";
			echo "<p>You are purchasing <b>$quantity</b> widget(s) at a cost 
			of <b>$price</b> each. With tax,
			the total comes to <b>\$$total</b></p>\n";

			//print the results using single quotation marks
			echo '<h3>Using single quotation marks:</h3>';
			echo '<p>You are purchasing <b>$quantity</b> widget(s)
			at a cost of <b>\$$price</b> each. With tax, the total
			comes to <b>\$$total</b></p>\n';
		?>
	</body>
</html>