Fragmented Thought

Bulk Updating Magento Product Prices



Lance Gliser

Heads up! This content is more than six months old. Take some time to verify everything still works as expected.

This one is more than a personal gripe, there's a valid server related issue when you write shorthand PHP code. If you are one of those people doing <? ?> stop now.

You get into an issue of "is this php or xml" since you share the same opening tag. There's also a number servers out there that have the shorthand coding option turned off. Stop with the shorthand, all you do is create instability.

For those of you who happen to inherit a failure that uses these kinds of markup, here's a couple of replacements you can run over the code to clean it up for you. Run them in the order presented, you have to clear out the shorthand prints before taking care of the regular shorthand.

Shorthand Print Correction (Simple string replace)

<?= // Shorthand print <?php print //Proper print

Shorthand PHP Opener Correction (Regex)

/\<\?[php]*/ // Shorthand print <?php print

Make sure to include the trailing space, as it's 'legal' to do something like <?#comment, but that break <?php.