Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi everybody,

I'm dusting off my PHP with this book. I'm using a kindle edition.

 

In chapter 2 I can read:

 

$months = [1 => 'January',
 'February', 'March', 'April',
 'May', 'June', 'July', 'August',
 'September', 'October',
 'November', 'December'];
 
This doesn't work for me (PHP 5.3.1)
 
I think it should read:
$months = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); 
 
 
Link to comment
Share on other sites

Yeah, the short array syntax, shown there, was added in PHP 5.4. On earlier versions of PHP you'll need to use the older, longer syntax. This is explained earlier in the chapter when the short array syntax is introduced. 

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...