Jump to content
Larry Ullman's Book Forums

yrocs

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by yrocs

  1. I'm using PHP 7.0.13, so it doesn't look like things have changed since the book was published (unless there's some new setting you can change). Of course, my real question is why this code causes a parse error. It's not at all obvious to me what the problem is (and it's not explained in the book). >>With your example, that's a fair use, too, although you want to do this, I'm pretty sure: echo "He drank some juice made of {$juice}s." Indeed. The example is taken right from the PHP online manual, and if you take another look at the example code (the "Valid" example), that's exactly what they did.
  2. From chapter 2, Introducing Arrays, p. 55: Can you elaborate on how the quotes "muddles" the syntax? From what I understand, the curly braces are needed in cases where the last character of the variable name is ambiguous, such as: <?php $juice = "apple"; // Invalid. "s" is a valid character for a variable name, but the variable is $juice. echo "He drank some juice made of $juices."; // Valid. Explicitly specify the end of the variable name by enclosing it in braces: echo "He drank some juice made of ${juice}s." ?> But in the case of an associative array variable, like $states['IL'], what is the potential problem here (what specifically is the need for the braces)? Thank you.
×
×
  • Create New...