Blank output often means a fatal error in the PHP code of the snippet or (less often) invalid HTML produced by the snippet. If it’s a PHP error, it’s most often a missing brace, semicolon, quotation mark, mistyped comment open or close, or unmatched parentheses.
Here’s code with a couple of common errors:
<?php
$x=1;
$y=2;
$z=3;
if ($x == ($y + $Z) {
doThis();
}
?>
If you have a code editor with syntax highlighting, it can help you find these errors. There’s a MODx plugin to add syntax highlighting in the Manager
http://modxcms.com/GeSHi-Syntax-Highlighter-0.4-0.html, I haven’t used it but people seem to like it. I don’t know if it works with the current version of MODx.
Another way to find an error (if it’s not obvious) is to go here:
http://www.icosaedro.it/phplint/phplint-on-line.html. Paste the snippet code into the upper window, turn off everything but errors (e.g. turn off warnings and notices), and click on the "parse" button.
If there’s a fatal error in your PHP code, the report below will end just after that error. The PHPLint error message isn’t always helpful, but at least you know where to look for the error.
Here’s the PHPLint report for the code above:
1: <?php
2:
3: $x=1;
4: $y=2;
5: $z=3;
6:
7: if ($x == ($y + $Z) {
if ($x == ($y + $Z) {
\_ HERE
**** 7: ERROR: variable `$Z’ has not been assigned
if ($x == ($y + $Z) {
\_ HERE
**** 7: FATAL ERROR: expected closing ’)’ after ’if’ condition, found symbol sym_lbrace
Creating a PHPLint plugin (or Module) for MODx is left as an exercise for the reader.