PHP语法 - 打破一行参数并返回/ echo

Using arrays, I see quit often the following formatting :

$somearray = array( 'one'=>'one_value',
                    'twokey'=>'two_value',
                    'some_third_value'=>'some_other_value',
                    '987654'=>'12340987',
                    'confused_yet_456789'=> $some_var,
                    'confused_yet_rt78466'=>'two_value'
                    );

that is of course instead of the one liner :

$somearray = array( 'one'=>'one_value','twokey'=>'two_value','some_third_value'=>'some_other_value','987654'=>'12340987','confused_yet_456789'=> $some_var,'confused_yet_456789'=>'two_value');

However , I for myself have never encountered or seen it used in a functions $parameters assignment, e.g :

function my_function_3($somevar='some_value_or_other',$title='some_87654_num_value',$cool_stuff='right_or_left',$dashboards='91234765',$menu='some_6374_menu'){

return $cool_stuff;

}

Expanded to :

function my_function_3( $somevar='some_value_or_other',
                        $title='some_87654_num_value',
                        $cool_stuff='right_or_left',
                        $dashboards='91234765',
                        $menu='some_6374_menu'
                        ){
return $cool_stuff;
}   

The same goes for echo or return.

From this :

$output .= '<img src="http://chart.apis.google.com/chart?cht=qr&chs='.$qr_size .'x'.$qr_size .'&chld=L|4&chl=' .  $string . '" width="'.$qr_size.'" height="'.$qr_size.'" alt="Some alt to describe QR code" title="QR code for your phone"/>';

to this :

 $output .= '<img src="http://chart.apis.google.com/chart?cht=qr&chs='.
                $qr_size .'x'.
                $qr_size .'&chld=L|4&chl=' .  
                $string . '" width="'.
                $qr_size.'" height="'.
                $qr_size.'" alt="Some alt to describe QR code" title="QR code for your phone"/>';

So , my question is :

Can I use this syntax or formatting also in $parameters assignment in a function, as well as echo / return ?

if no - why ? can it fail on certain configs ? is it just wrong ?

..and if yes , what is the correct way to do so (break the line BEFORE or AFTER the comma / dot ) ??

Yes you can use new lines anywhere it PHP. They don't have any syntactic meaning like they do in Javascript (where a new line means terminate the current statement) or Java where new lines can't be used within strings.

In fact all whitespace is trimmed within PHP, not just newlines, but spaces and tabs as well.

what is the correct way to do so

That is a matter of taste but I prefer to have the dot/comma before the new line, as that produces code that is easiest to read.

Slightly more controversially, if the parameters won't fit on a single line easily, I also prefer to have the multi-line parameters use one tab more indentation than the code they're in, rather than aligning with the bracket of the function.

$arg1 = simpleFunction();
$arg2 = simpleFunction2($arg1);

$result = testFunctionWithManyParameters(
  $arg1,
  $arg2,
  $arg3,
  $arg4,
  $arg5
);

As again, imho, it makes reading the code easier than having them indented massively.

$result = testFunctionWithManyParameters($arg1, $arg2, $arg3, $arg4, $arg5 );