Set default <?php in the text area to restore syntax highlighting, fixes #10

master
Jordi Boggiano 12 years ago
parent d8f52798c6
commit 10520c59cb
  1. 6
      index.php
  2. 5
      php-console.js

@ -33,12 +33,12 @@ error_reporting(E_ALL | E_STRICT);
$debugOutput = '';
if (isset($_POST['code'])) {
$code = $_POST['code'];
if (get_magic_quotes_gpc()) {
$code = stripslashes($code);
}
$code = trim(preg_replace('{^\s*<\?(php)?}i', '', $_POST['code']));
// if there's only one line wrap it into a krumo() call
if (preg_match('#^(?!var_dump|echo|print|< )([^\r\n]+?);?\s*$#is', $code, $m) && trim($m[1])) {
$code = 'krumo('.$m[1].');';
@ -88,7 +88,7 @@ if (isset($_POST['code'])) {
<div class="output"><?php echo $debugOutput ?></div>
<form method="POST" action="">
<div class="input">
<textarea class="editor" id="editor" name="code"><?php echo (isset($_POST['code']) ? htmlentities($_POST['code'], ENT_QUOTES, 'UTF-8') : null) ?></textarea>
<textarea class="editor" id="editor" name="code"><?php echo (isset($_POST['code']) ? htmlentities($_POST['code'], ENT_QUOTES, 'UTF-8') : "&lt;?php\n\n") ?></textarea>
<div class="statusbar">
<span class="position">Line: 1, Column: 1</span>
<span class="copy">

@ -80,9 +80,8 @@
var PhpMode, code;
code = $('#' + options.editor).text();
$('#' + options.editor)
.replaceWith('<div id="'+options.editor+'" class="'+options.editor+'"></div>')
.text(code);
$('#' + options.editor).replaceWith('<div id="'+options.editor+'" class="'+options.editor+'"></div>');
$('#' + options.editor).text(code);
editor = ace.edit(options.editor);

Loading…
Cancel
Save