09.07.2005, 17:53
greg, deine Funktion funktioniert nicht.
Ich habe eine Datei genommen mit der Funktion
[code:1]
<?php
function php($str) {
if(preg_match("§[code](.*)[/code]§Uis", $str, $matches))
{
$str = preg_match("§[code](.*)[/code]§Uis", $str, $matches);
$matches[0] = @preg_replace("/[code](.*)[/code]/Uis","\1", $matches[0]);
if($matches[0] != "")
{
$matches[0] = stripslashes($matches[0]);
$matches[0] = html_entity_decode($matches[0]);
$matches[0] = str_replace("<br />", "", $matches[0]);
$str = highlight_string($matches[0],true);
$str = substr_replace($str,"<i>PHP - Code</i><br />",0,0);
return $str;
}
}
}
$bla=file_get_contents('./greg2.php');
echo php($bla);
?>
[/code:1]
Und dann noch die greg2.php
[code:1]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
</head>
<body>
[code]
<?php
echo "bla";
?>
[/code]
[code]
<?php
echo "blubb";
?>
[/code]
</body>
</html>[/code:1]
Es wird aber nur
<?php
echo "bla";
?>
ausgegeben, mehr nicht.
<?php
echo "blubb";
?>
wird völlig ignoriert.
Ich habe eine Datei genommen mit der Funktion
[code:1]
<?php
function php($str) {
if(preg_match("§[code](.*)[/code]§Uis", $str, $matches))
{
$str = preg_match("§[code](.*)[/code]§Uis", $str, $matches);
$matches[0] = @preg_replace("/[code](.*)[/code]/Uis","\1", $matches[0]);
if($matches[0] != "")
{
$matches[0] = stripslashes($matches[0]);
$matches[0] = html_entity_decode($matches[0]);
$matches[0] = str_replace("<br />", "", $matches[0]);
$str = highlight_string($matches[0],true);
$str = substr_replace($str,"<i>PHP - Code</i><br />",0,0);
return $str;
}
}
}
$bla=file_get_contents('./greg2.php');
echo php($bla);
?>
[/code:1]
Und dann noch die greg2.php
[code:1]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
</head>
<body>
[code]
<?php
echo "bla";
?>
[/code]
[code]
<?php
echo "blubb";
?>
[/code]
</body>
</html>[/code:1]
Es wird aber nur
<?php
echo "bla";
?>
ausgegeben, mehr nicht.
<?php
echo "blubb";
?>
wird völlig ignoriert.

