Script 1.10 Quotations

Experiment with using single versus double quotation marks to see how variables respond during interpretation.

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
Source
<?php	
#	Script	1.10	-	quotes.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';
?>