I have a jQuery image rotating script that I found, which uses a line like this to call the images that get rotated:
<?=$image_rotation; ?>
When I save this as a snippet, MODx rewrites it thusly:
<?php
=$image_rotation;
?>
And then I get this lovely error on the page with the script on it:
Parse error: syntax error, unexpected ’=’ in /home/jademoun/public_html/manager/includes/document.parser.class.inc.php(769) : eval()’d code on line 1
I understand why I get the error, but I can’t figure out how to resolve it. I understand that <?= is shorthand for something in PHP, but I’m not sure what, and that’s a hard thing to Google for. Any help would be appreciated!
Try it with this as your snippet code:
<?php
$output ="";
$output .=$image_rotation;
return $output;
?>
-
☆ A M B ☆
- 24,524 Posts
That’s shorthand for echo. You shouldn’t use echo in snippets, all output should be gathered into a variable and returned.