This works:
echo $quotations [4];
echo "<br />";
echo $quotations [5];
echo "<br />";
echo "The PHP End";
This doesn't:
echo "$quotations [4] <br /><br /> $quotations [5] <br /><br />";
Am I misunderstanding string interpolation?
A.
This works:
echo $quotations [4];
echo "<br />";
echo $quotations [5];
echo "<br />";
echo "The PHP End";
This doesn't:
echo "$quotations [4] <br /><br /> $quotations [5] <br /><br />";
Am I misunderstanding string interpolation?
A.
PHP doesn't realize that the indices are part of the variables - it thinks they're part of the string.PHP Code:echo "$quotations [4] <br /><br /> $quotations [5] <br /><br />";
You can resolve the ambiguity by using brackets:(Incidentally, see how you can tell what's wrong by looking at the colors in the code highlighting? When you code, use an editor that does that. very helpful.)PHP Code:echo "{$quotations[4]}<br>{$quotations[5]}<br>";
marain (05-13-2012)
Bookmarks