0

Today I found a block of code where an array was declared like this:

$array = ['user'|'manager'|'admin'];

Into the code context, the array is used to keep references of some classes named 'User', 'Manager' and 'Admin' respectively.

At first impression I thought that was a new array's separator for PHP 7 or something similar. But testing I get confused:

$array = ['user'|'manager'|'admin'];
var_dump($array);

// result:
array:1 [
  0 => "}wo{oer"
]

In other test, I used only letters:

$array = ['a'|'b'|'c'];

array:1 [▼
  0 => "c"
]


$array = ['a'|'b'];

array:1 [▼
  0 => "c"
]

I asked to the author what his code means, but I never receive response.

manix
  • 13,613
  • 9
  • 64
  • 98

0 Answers0