What is the difference between array() and [] syntax in PHP?
Why Interviewers Ask This
This is a classic screening question for PHP roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.
Answer
Both array() and [] create arrays in PHP — they are functionally identical. The [] short syntax was introduced in PHP 5.4 and is now universally preferred because it is more concise and reads like array literals in other languages. $fruits = ["apple", "banana"] is exactly equivalent to $fruits = array("apple", "banana"). The short syntax also works for destructuring assignments (PHP 7.1+): [$first, $second] = $array; as opposed to list($first, $second) = $array;. Modern PHP code almost exclusively uses the short [] syntax.
Pro Tip
If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.