Problem mit str_replace()

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Problem mit str_replace()

    Hi, ich habe ein kleines Problem mit str_replace...

    Inahlt der index.php :

    <?PHP include("login/include.php"); ?>
    {LOGINBOX}

    Inhalt der include.php :

    PHP-Code:
    <?PHP
    $root 
    "login/";
    $loginbox_template file_get_contents($root."templates/login_box.tpl");
    $self=$PHP_SELF;
    $ausgabe str_replace("{LOGINBOX}",$loginbox_template,$self);
    ?>
    Soweit ich die str_replace funtion verstehe, müsste nun das {LOGINBOX} in der index.php durch den Inahlt von templates/login_box.tpl ersetzt werden... also, durch die loginbox ausgetauscht werden. Dies funktioniert aber leider nicht.

  • #2
    müsste nun das {LOGINBOX} in der index.php durch den Inahlt von templates/login_box.tpl ersetzt werden
    Aber nur innerhalb des Strings von $PHP_SELF und dort kommt wohl dein {LoginBox} nicht vor.
    Du suchst etwas wie das
    PHP-Code:
    $ausgabe str_replace("{LOGINBOX}",$loginbox_template,readfile($_SERVER['PHP_SELF'])); 
    Gruss

    tobi
    Zuletzt geändert von jahlives; 08.09.2006, 17:37.
    Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

    [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
    Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

    Kommentar


    • #3
      mhh... nun bekomme ich folgende Fehlermeldung:

      Warning: readfile(): open_basedir restriction in effect. File(/index.php) is not within the allowed path(s): (/home/www/web2/html/:/home/www/web2/phptmp/:/home/www/web2/files/:/home/www/web2/atd/) in /home/www/web2/html/login/include.php on line 19

      Warning: readfile(/index.php): failed to open stream: Operation not permitted in /home/www/web2/html/login/include.php on line 19

      Kommentar


      • #4
        In welchem Verzeichnis liegt denn deine index.php ?
        Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

        [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
        Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

        Kommentar


        • #5
          Die index.php liegt im Verzeichnis html/
          und die include.php liegt im Verzichnis html/login/

          Kommentar


          • #6
            Warning: readfile(): open_basedir restriction in effect. File(/index.php)
            Dann ist /index.php ja definitiv falsch!!

            Nee...
            da läuft irgend eine Denke grundsätzlich falsch...
            Wir werden alle sterben

            Kommentar


            • #7
              Setzt mal dsa verzeichnes von index auf root/html/
              Webdesign und Webentwicklung - Plunix.de

              Kommentar


              • #8
                Hallo!!!
                readfile hat innerhalb von str_replace nicht zu suchen, da readfile als rückgabewert ein int liefert.
                Jetzt sag bitte was du wirklich willst?
                wenn du die ausgabe von deinem script dadurch beeinflüssen willst, dann muss du anderes vorgehen.
                nicht getestet:
                PHP-Code:
                <?php
                //include.php 
                function loginbox($inhalt){
                $loginbox_template file_get_contents("richtigepfad_zur_template.tpl");
                return 
                str_replace("{LOGINBOX}",$loginbox_template,$inhalt);
                }
                 
                ob_start("loginbox");
                ?>
                jetzt kannst du diese datei includen.
                Aber ehrlich gesagt, gefehlt mir so ein Art von programmierung gar nicht
                Zuletzt geändert von Slava; 09.09.2006, 01:57.
                Slava
                bituniverse.com

                Kommentar


                • #9
                  mhh... das tut auch nit. Es erscheint nur weiß...

                  Also... ich erklär ma für was es genau sein soll...
                  In der Datei index.php ist irgendwo.... {LOGINBOX}
                  drin... wenn man die Seite aber nun aufruft wird das {LOGINBOX}
                  durch das Template templates/loginbox.tpl ersetzt.

                  Kommentar


                  • #10
                    mhh... das tut auch nit. Es erscheint nur weiß...

                    Also... ich erklär ma für was es genau sein soll...
                    In der Datei index.php ist irgendwo.... {LOGINBOX}
                    drin... wenn man die Seite aber nun aufruft wird das {LOGINBOX}
                    durch das Template templates/loginbox.tpl ersetzt.
                    Sorry aber das ist vollkommener Murks. Wenn man die index.php aufruft, kannst du nichts mehr in der Datei ersetzen.

                    Imo gehört in PHPDateien auch wirklich nur PHP, und nichts anderes. (Außgenommen natürlich MySQL & sonstige Serverseitigen Sprachen). Wieso includest du nicht einfach dsa Template? Dann musst du nichts ersetzen, etc. Ich verstehe deinen Gedankengang nicht genau. Ansonsten, arbeite mit Templates.

                    Kommentar

                    Lädt...
                    X