Differences Between Types of Quotation Marks
You likely noticed that when we were working with print( ) and echo( ) I
made use of both single and double quotation marks. In many settings
there isn't really much to distinguish between their use characteristics.
While this isn't likely to mean too much at present, things between two single quotation marks are treated literally. Things between double quotation marks will be interpolated. For example, assume we have the following two code snippets.
The code snippet
Another two examples of the same ilk are
But the code snippet
These examples should illustrate that using " will cause the value of a variable to be displayed.
The following is a modification of our very_basic_variables.php which should now be called very_basic_quotes.php.
<title>Some Very Basic Work With Variables</title>
<body bgcolor="005544" text="d0d0d0">
// assigning the information and displaying it
// using both double and single quotation marks
$first_number = 1.234;
print "<P>Using \" the first variable \$first_number has value <b>$first_number</b><BR>";
print 'Using \' the first variable \$first_number has value <b>$first_number</b></P>';
$second_number = 37.33;
echo "<P>Using \" the second variable \$second_number has value <b>$second_number</b><BR>";
echo 'Using \' the second variable \$second_number has value <b>$second_number</b></P>';
$product = $first_number * $second_number;
print "<P>Using \" the product of these two numbers \$product is <b>$product </b><BR>";
print 'Using \' the product of these two numbers \$product is <b>$product </b></P>';
|After uploading and running this in your account on the server you should see something like the following. Though this presents only the very beginning of the results.|
|We'll look this over in class and discuss a few of the reported settings.|