<!DOCTYPE html> <html> <body> [[SyntaxHighlighter? &brushes=`css,php`]] <h2>Example PHP</h2> <pre class="brush: php"><fixedpre> <?php $t = date("H"); echo "<p>The hour (of the server) is " . $t; echo ", and will give the following message:</p>"; if ($t < "10") { echo "Have a good morning!"; } elseif ($t < "20") { echo "Have a good day!"; } else { echo "Have a good night!"; } ?> </fixedpre></pre> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="[[++modx_charset]]"> <meta content="IE=edge" http-equiv="X-UA-Compatible"> <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport'> <title>Syntax highlighter</title> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/styles/shThemeDefault.css" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/styles/shCore.css" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shCore.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shAutoloader.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shBrushJScript.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shBrushPhp.js"></script> <script type="text/javascript"> SyntaxHighlighter.all() </script> </head> <body> [[*content]] </body> </html>
<h2>Example javascript highlighter with script-tag</h2> <script type="syntaxhighlighter" class="brush: js"><![CDATA[ /** * SyntaxHighlighter */ function foo() { if (counter <= 10) return; // it works! } ]]></script> <h2>Example php highlighter with pre-tag AND the modx fixedpre-plugin</h2> <pre class="brush: php"><fixedpre> <?php $t = date("H"); echo "<p>The hour (of the server) is " . $t; echo ", and will give the following message:</p>"; if ($t < "10") { echo "Have a good morning!"; } elseif ($t < "20") { echo "Have a good day!"; } else { echo "Have a good night!"; } ?> </fixedpre></pre> <h2>Example php highlighter with script-tag</h2> <script type="syntaxhighlighter" class="brush: php"><![CDATA[ <?php // define variables and set to empty values $name = $email = $message = ""; if ($_SERVER["REQUEST_METHOD"] == 'POST') { $name = test_input($_POST["name"]); $email = test_input($_POST["email"]); $message = test_input($_POST["message"]); } // Check fields with function test_input() function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> ]]></script>