online 1
gast (50)

/ Forum / Skripte(PHP,ASP,Perl...)

Skripte(PHP,ASP,Perl...)Skripte(PHP,ASP,Perl...)

Fragevon Fassy91 vom 14.11.2019, 23:13 Options

Class und str_replace problem

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 :
<?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="";
    }
  }
?>


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">&copy; 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 schreiben

Antwort 1 von Fassy91 vom 15.11.2019, 14:43 Options

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

Ähnliche Themen

von benutzer defenierte methode
js_rulez  23.07.2007 - 40 Hits - 4 Antworten

Kleines Problem mit DOM und FireFox
Dr.Ma-Busen  03.12.2007 - 59 Hits - 3 Antworten

suche kosenlose webspace wo man auch *.class unterladen kann
Dreamteam1130  15.12.2007 - 93 Hits - 1 Antwort

FSB OC des MSI K9N6GM - V Class
Etoxa  19.01.2008 - 23 Hits -

Hinweis

Diese Frage ist schon etwas älter, Sie können daher nicht mehr auf sie antworten. Sollte Ihre Frage noch nicht gelöst sein, stellen Sie einfach eine neue Frage im Forum..

Neue Einträge

Version: supportware 1.9.150 / 10.06.2022, Startzeit:Thu Jan 8 21:07:44 2026