Why do PHP Array Examples Leave a Trailing Comma?

后端 未结 10 1588

I have seen examples like the following:

$data = array(
   \'username\' => $user->getUsername(),
   \'userpass\' => $user->getPassword(),
   \'em         


        
10条回答
  •  温柔的废话
    2020-12-05 09:42

    I'm always doing trailing comma because it helps to avoid syntax errors while adding new array elements... it's just a good practice.

提交回复
热议问题