-2

I was going through a manual and found a statement saying "if array element used with '-' as the word separator, the array's element can be accessed by magic quotes".. but didn't provided with any explanations on it. could some one explain the reason behind this?

OM The Eternity
  • 15,694
  • 44
  • 120
  • 182

1 Answers1

2

It's seemingly this one (since OP won't tell us):
http://www.dagbladet.no/development/phpcodingstandard/#arrayelement

Here "magic quotes" is simply the wrong designation. They mean double quoted string interpolation, specifically:

print "$myarr[foo_bar] world"; 

versus

print "$myarr[foo-bar] world";   // invalid

And indeed only the first one is correct syntax. Else use curly braces and key quotes:

print "{$myarr['foo-bar']} world";
mario
  • 144,265
  • 20
  • 237
  • 291
  • Hey Yes.. This is the manual They Have used... But here also They have menioned about the "magic quotes" in justification – OM The Eternity Jan 31 '12 at 10:41
  • Is the same misdesignation. They are talking about double quoted strings once more. The warnings are notices for undeclared constants. Which is what happens for unquoted array keys in PHP code, not in double quote context. – mario Jan 31 '12 at 11:10