数组转储在 5.6 但不是 PHP 5.5.9
Array dumps in 5.6 but not PHP 5.5.9
正在尝试:
var_dump(Map::map);
在 PHP 5.5.9 这给了我
解析错误:语法错误,意外的 '.',期待第 14 行 map.php 中的 ']'(即下面数组声明中的第一个连接标记)
在 PHP 5.6 中,它会在没有任何警告或通知的情况下转储数组。
class Map
{
const map = [
'admin' => [
'' => __DIR__ . 'somefile.php'],
'resa' => __DIR__ . 'somefile.php',
'galleri' => __DIR__ . 'somefile.php',
'kategori' => __DIR__ . 'somefile.php',
'' => [
'' => __DIR__ . 'somefile.php',
'katalog' => __DIR__ . 'somefile.php',
'resan' => __DIR__ . 'somefile.php',
'bussresor' => __DIR__ . 'somefile.php',
'kontakt' => __DIR__ . 'somefile.php'],
'ajax' => __DIR__ . 'somefile.php',
'test' => [
'' => __DIR__ . 'somefile.php',
'test1sub' => __DIR__ . 'somefile.php',
'test2' => [
'' => __DIR__ . 'somefile.php',
'test2sub' => __DIR__ . 'somefile.php',
'test3' => [
'' => __DIR__ . 'somefile.php',
'test3sub' => __DIR__ . 'somefile.php'
]
]
]
];
}
这是因为PHP5.6引入了常量数组。在5.5~会导致解析错误。
正在尝试:
var_dump(Map::map);
在 PHP 5.5.9 这给了我 解析错误:语法错误,意外的 '.',期待第 14 行 map.php 中的 ']'(即下面数组声明中的第一个连接标记)
在 PHP 5.6 中,它会在没有任何警告或通知的情况下转储数组。
class Map
{
const map = [
'admin' => [
'' => __DIR__ . 'somefile.php'],
'resa' => __DIR__ . 'somefile.php',
'galleri' => __DIR__ . 'somefile.php',
'kategori' => __DIR__ . 'somefile.php',
'' => [
'' => __DIR__ . 'somefile.php',
'katalog' => __DIR__ . 'somefile.php',
'resan' => __DIR__ . 'somefile.php',
'bussresor' => __DIR__ . 'somefile.php',
'kontakt' => __DIR__ . 'somefile.php'],
'ajax' => __DIR__ . 'somefile.php',
'test' => [
'' => __DIR__ . 'somefile.php',
'test1sub' => __DIR__ . 'somefile.php',
'test2' => [
'' => __DIR__ . 'somefile.php',
'test2sub' => __DIR__ . 'somefile.php',
'test3' => [
'' => __DIR__ . 'somefile.php',
'test3sub' => __DIR__ . 'somefile.php'
]
]
]
];
}
这是因为PHP5.6引入了常量数组。在5.5~会导致解析错误。