Supportnet / Forum / Skripte(PHP,ASP,Perl...)
Class und str_replace problem
Frage
Hallo an alle,
ich habe mir selber einen kleinen Styler geschreiben der in einer styledatei durch ersetzen den style zusammenbaut.
Aber irgendwie klappen die str_replaces net.
Ich hoffe ihr könnt mir die Fehler aufweisen.
PHP Klasse :
[code]<?php
class Style
{
var $currentstyledata;
function init()
{
$file = fopen("style/styledata.mlt",r);
$size = filesize("style/styledata.mlt");
$filein = fread($file,$size);
fclose($file);
$this->currentstyledata=$filein;
}
function top($inhalt)
{
str_replace("PlaceholderId : h1",$inhalt,$this->currentstyledata);
}
function nav($inhalt)
{
str_replace("PlaceholderId : Nav",$inhalt,$this->currentstyledata);
}
function main($inhalt)
{
str_replace("PlaceholderId : Main",$inhalt,$this->currentstyledata);
}
function display()
{
if($this->currentstyledata)
{
print($this->currentstyledata);
}
$this->currentstyledata="";
}
}
?>
[/code]
Und die Styledatei :
<html>
<head>
<title>Paradise | Der etwas andere Obstladen</title>
<link rel="stylesheet" type="text/css" href="style/css/main.css">
</head>
<body>
<div id="container">
<div id="content">
<h1 id="site-title"><a href="index.php">Paradise<img src="style/img/v2.gif"></a></h1>
<p id="site-description">hier kriegen sie alles was sie brauchen/p>
<h1 class="decay">PlaceholderID : h1</h1>
PlaceholderID : Main
<div class="descr">Nov 14, 2007 by Superkanake,Keygenmaster</div>
<div id="footer">
<span class="left">© 2008 <a href="index.php">paradise</a>. </span>
<div class="clearer"><span></span></div>
</div>
</div>
<div id="navigation">
PlaceholderID : Nav
</div>
</div>
</body>
</html>
Antwort 1 von Fassy91
ich hab das problem gefunden und schon gelöst.
Jetzt sieht es so aus :
<?php
class Style
{
var $currentstyledata;
function init()
{
$file = fopen("style/styledata.mlt",r);
$size = filesize("style/styledata.mlt");
$filein = fread($file,$size);
fclose($file);
$this->currentstyledata=$filein;
}
function top($inhalt)
{
$newstring = str_replace("PlaceholderID : h1",$inhalt,$this->currentstyledata);
$this->currentstyledata=$newstring;
}
function nav($inhalt)
{
$newstring = str_replace("PlaceholderID : Nav",$inhalt,$this->currentstyledata);
$this->currentstyledata=$newstring;
}
function main($inhalt)
{
$newstring = str_replace("PlaceholderID : Main",$inhalt,$this->currentstyledata);
$this->currentstyledata=$newstring;
}
function display()
{
if($this->currentstyledata)
{
print($this->currentstyledata);
}
$this->currentstyledata="";
}
}
?>
thx trotzdem
Jetzt sieht es so aus :
<?php
class Style
{
var $currentstyledata;
function init()
{
$file = fopen("style/styledata.mlt",r);
$size = filesize("style/styledata.mlt");
$filein = fread($file,$size);
fclose($file);
$this->currentstyledata=$filein;
}
function top($inhalt)
{
$newstring = str_replace("PlaceholderID : h1",$inhalt,$this->currentstyledata);
$this->currentstyledata=$newstring;
}
function nav($inhalt)
{
$newstring = str_replace("PlaceholderID : Nav",$inhalt,$this->currentstyledata);
$this->currentstyledata=$newstring;
}
function main($inhalt)
{
$newstring = str_replace("PlaceholderID : Main",$inhalt,$this->currentstyledata);
$this->currentstyledata=$newstring;
}
function display()
{
if($this->currentstyledata)
{
print($this->currentstyledata);
}
$this->currentstyledata="";
}
}
?>
thx trotzdem

