Scripts
PHP Highlight Scriptje
Als aller eerst, dit is niet door mij gemaakt.. Ik post dit omdat mensen het mischien nodig hebben =) Met dit scriptje kan je je code even na loopen in de high light. Voer je PHP code in, druk op de button en zie het resultaat!
php-highlight-scriptje
index.php:
[code]
<?php
include_once 'init.inc.php';
if (!empty($_POST['text'])){
echo '<div style="border: solid 1px orange; padding: 20px; margin: 20px">';
highlight_string($_POST['text']);
echo '</div>';
exit;
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<textarea name="text" style="width: 300px; height: 200px"></textarea>
<br />
<input type="submit" />
</form>
[/code]
init.inc.php:
<?php
// figure out the if ":" or ";" should be used for ini separators
if (strpos(strtoupper(PHP_OS), "WIN") !== false) {
define("INI_PATH_SEPARATOR", ";");
} else {
define("INI_PATH_SEPARATOR", ":");
}
// add PEAR to the path
ini_set(
"include_path",
ini_get("include_path") . INI_PATH_SEPARATOR .
realpath("PEAR")
);
// stripslashes as shown on http://php.net/get_magic_quotes_gpc
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}
?>
hilight.css:
[code]
.hl-default {
color: Black;
}
.hl-code {
color: Gray;
}
.hl-brackets {
color: Olive;
}
.hl-comment {
color: Orange;
}
.hl-quotes {
color: Darkred;
}
.hl-string {
color: Red;
}
.hl-identifier {
color: Blue;
}
.hl-builtin {
color: Teal;
}
.hl-reserved {
color: Green;
}
.hl-inlinedoc {
color: Blue;
}
.hl-var {
color: Darkblue;
}
.hl-url {
color: Blue;
}
.hl-special {
color: Navy;
}
.hl-number {
color: Maroon;
}
.hl-inlinetags {
color: Blue;
}
.hl-main {
background-color: White;
}
.hl-gutter {
background-color: #999999;
color: White
}
.hl-table {
font-family: courier;
font-size: 12px;
border: solid 1px Lightgrey;
}
[/code]
Reacties
0