Skip to content

Increment and arrays creates unparsable PHP code #8

Skrupellos opened this Issue Sep 11, 2011 · 0 comments

1 participant



Use Opt 2.1 beta 1 and execute a post-increment operation (and probably other, related operations) on arrays, like in the example below.



This results in really wired PHP code, which ends up with a parser error.

<?php echo $ctx->_data['list']++$ctx->_data['list']++['index']++;   ?>
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in foo.tpl.php


... parseable PHP code like the following.

<?php echo $ctx->_data['list']['index']++;   ?>


Using no arrays (from a template point of view), works. The following template creates the correct PHP code shown afterwards.

<?php echo $ctx->_data['foo']++;   ?>

A similar problem (probably caused by the same reason) is an array assignment like the following template and compiled PHP code shows.

{$item.type is 'Location'}
<?php $ctx->_data['item']='Location'['type']='Location';   ?>


Create a copy of the array value and modify that copy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.