index.html 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <!doctype html>
  2. <title>CodeMirror: PHP mode</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../../doc/docs.css">
  5. <link rel="stylesheet" href="../../lib/codemirror.css">
  6. <script src="../../lib/codemirror.js"></script>
  7. <script src="../../addon/edit/matchbrackets.js"></script>
  8. <script src="../htmlmixed/htmlmixed.js"></script>
  9. <script src="../xml/xml.js"></script>
  10. <script src="../javascript/javascript.js"></script>
  11. <script src="../css/css.js"></script>
  12. <script src="../clike/clike.js"></script>
  13. <script src="php.js"></script>
  14. <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
  15. <div id=nav>
  16. <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
  17. <ul>
  18. <li><a href="../../index.html">Home</a>
  19. <li><a href="../../doc/manual.html">Manual</a>
  20. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  21. </ul>
  22. <ul>
  23. <li><a href="../index.html">Language modes</a>
  24. <li><a class=active href="#">PHP</a>
  25. </ul>
  26. </div>
  27. <article>
  28. <h2>PHP mode</h2>
  29. <form><textarea id="code" name="code">
  30. <?php
  31. $a = array('a' => 1, 'b' => 2, 3 => 'c');
  32. echo "$a[a] ${a[3] /* } comment */} {$a[b]} \$a[a]";
  33. function hello($who) {
  34. return "Hello $who!";
  35. }
  36. ?>
  37. <p>The program says <?= hello("World") ?>.</p>
  38. <script>
  39. alert("And here is some JS code"); // also colored
  40. </script>
  41. </textarea></form>
  42. <script>
  43. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  44. lineNumbers: true,
  45. matchBrackets: true,
  46. mode: "application/x-httpd-php",
  47. indentUnit: 4,
  48. indentWithTabs: true
  49. });
  50. </script>
  51. <p>Simple HTML/PHP mode based on
  52. the <a href="../clike/">C-like</a> mode. Depends on XML,
  53. JavaScript, CSS, HTMLMixed, and C-like modes.</p>
  54. <p><strong>MIME types defined:</strong> <code>application/x-httpd-php</code> (HTML with PHP code), <code>text/x-php</code> (plain, non-wrapped PHP code).</p>
  55. </article>