Jeg fandt denne mega fede feature hos
http://bluesome.net/post/2005/08/18/50/ Den kan gøre så du kan udskrive PHP fra din database f.eks. til en blog =)
functions.php
function eval_php($text) {
ob_start();
eval(" ?> $text <?php ");
$output = ob_get_contents();
ob_end_clean();
return $output;
}
function quote_smart($value) {
if (get_magic_quotes_gpc()) { $value = stripslashes($value); }
if (!is_numeric($value)) { $value = "'" . mysql_real_escape_string($value) . "'"; }
return $value;
}
function replacer($text) {
$text = eval_php($text);
$text = nl2br($text);
return $text;
}
Blogger.php >
require_once("functions.php");
mysql_connect("localhost", "root"); mysql_select_db("database");
$id = (int) $_GET[id];
if ($id > 0) {
$query = sprintf("SELECT * FROM `blogger` WHERE id=%s",quote_smart($id));
$row = mysql_fetch_array(mysql_query($query));
if (mysql_num_rows(mysql_query($query)) == 1) {
echo replacer($row[content]);
} else {
echo 'Not Found!';
}
} else {
echo 'Dont try anything funny!';
}
Databasen ser f.eks. sådan her ud :D
database>blogger>content:
Test
<?php echo "Hallo World!"; ?>
Output:
Test
Hallo World!
There is a lot of things to think about, but nothing to worry about.
Everybody is special to your life!
Its nice to be important but it is more important to be nice.
Love is Forever but Friends are for Eternity.
Were you born to resist or be abused?