How does magic quotes access the array element containing “-” in name?

时光毁灭记忆、已成空白 提交于 2019-12-13 07:53:42

问题


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?


回答1:


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";


来源:https://stackoverflow.com/questions/9077741/how-does-magic-quotes-access-the-array-element-containing-in-name

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!