28 lines
1 KiB
XML
28 lines
1 KiB
XML
|
<documentation title="Array Key Spacing Restrictions">
|
||
|
<standard>
|
||
|
<![CDATA[
|
||
|
When referring to array items, only include a space around the index if it is a variable or the key is concatenated.
|
||
|
]]>
|
||
|
</standard>
|
||
|
<code_comparison>
|
||
|
<code title="Valid: Correct spacing around the index keys">
|
||
|
<![CDATA[
|
||
|
$post = $posts<em>[ </em>$post_id<em> ]</em>;
|
||
|
$post_title = $post<em>[ </em>'concatenated' . $title<em> ]</em>;
|
||
|
$post = $posts<em>[ </em>HOME_PAGE<em> ]</em>;
|
||
|
$post = $posts<em>[</em>123<em>]</em>;
|
||
|
$post_title = $post<em>[</em>'post_title'<em>]</em>;
|
||
|
]]>
|
||
|
</code>
|
||
|
<code title="Invalid: Incorrect spacing around the index keys">
|
||
|
<![CDATA[
|
||
|
$post = $posts<em>[</em>$post_id<em>]</em>;
|
||
|
$post_title = $post<em>[</em>'concatenated' . $title<em> ]</em>;
|
||
|
$post = $posts<em>[</em>HOME_PAGE<em>]</em>;
|
||
|
$post = $posts<em>[ </em>123<em> ]</em>;
|
||
|
$post_title = $post<em>[ </em>'post_title'<em> ]</em>;
|
||
|
]]>
|
||
|
</code>
|
||
|
</code_comparison>
|
||
|
</documentation>
|