Einzelnen Beitrag anzeigen
  #1  
Alt 26.07.2017, 10:22:21
MikeDD MikeDD ist offline
Anfänger
 
Registriert seit: Jul 2017
Alter: 47
Beiträge: 4
Umstellung auf php7 - Warning: preg_replace(): The /e modifier is no longer supported

Hallo alle zusammen, ich bin neu hier und hoffe, dass ich das richtige Unterforum getroffen haben. Falls nicht, bitte ich um Nachsicht

Ich stelle meine Webseite gerade von php5 auf php7 um. Leider komme ich an einen Punkt nicht weiter. Ich habe eine Template Klasse. Unter php 5.6 lief diese fehlerfrei, muss jedoch aufgrund php7 umgestellt werden. Leider komme ich an dieser Stelle nicht weiter. Der Original Code ist folgender:

PHP-Code:
protected function replaceFunctions()
** *{

** * * *
// Includes ersetzen ( {include file="..."} )
** * * *while(preg_match("/".$this->leftDelimiterF."include file="(.*).(.*)"".$this->rightDelimiterF."/isUe"$this->template)) {
** * * * * *
$this->template preg_replace("/".$this->leftDelimiterF."include file="(.*).(.*)"".$this->rightDelimiterF."/isUe""file_get_contents(\$this->templateDir.'\\1'.'.'.'\\2')"$this->template);
** * * *}


** * * *
// Kommentare löschen
** * * *$this->template preg_replace("/".$this->leftDelimiterC."(.*)".$this->rightDelimiterC."/isUe"""$this->template);

** * * *return *
true;
** *} *


** *public function 
loop($name$array) {

** * * *
/*
** * * *Sucht nach Einträgen à la {loop=$name}{/loop} und sendet den Inhalt der Klammern an die Funktion loop_content()
** * * *Dabei werden der Name, der "Loop String" und der Datenarray übergeben
** * * **/

** * * *$this->template preg_replace("/".'\{loop="'.$name.'"}'."(.*)".'\{\/loop\}'."/isUe""\$this->loop_content(\$name, '\$1', \$array)"$this->template);
** *}




** *public function 
loop_content($name$string$array) {

** * * *
$output '';

** * * *
$string stripslashes($string); // Kleiner Fix für den String

** * * *foreach($array as $rows) { // Hier geht er den Datenarray durch

** * * * * *$string_tmp $string// Clone von $string, damit $string nicht überschrieben wird

** * * * * *foreach($rows as $row) { // Einzelne Objekte werden durchgegangen
** * * * * * * */*
** * * * * * * *Hier werden Werte à la {$name.key} mit den entsprechenden Werten aus dem Array ersetzt
** * * * * * * **/
** * * * * * * *$string_tmp str_replace($this->leftDelimiter.$name.".".key($rows).$this->rightDelimiter$row$string_tmp);
** * * * * * * *
next($rows); * *
** * * * * *}

** * * * * *
$output .= $string_tmp;
** * * *}

** * * *return 
$output;

** *} * 
Bei diesem Code bekomme ich folgende Fehler...

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /www/htdocs/w0xxxxx/abc/test.de/class/template.php on line 207

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /www/htdocs/w0xxxxx/abc/test.de/class/template.php on line 212

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /www/htdocs/w0xxxxx/abc/test.de/class/template.php on line 225



Folgendes habe ich bereits umgesetzt. Jedoch bin ich mir nicht sicher, ob dies so der richtige Weg ist...

PHP-Code:
protected function replaceFunctions()
** *{

** * * *
// Includes ersetzen ( {include file="..."} )

** * * *$this->template preg_replace_callback("/{include file="(.*).(.*)"}/",
** * * * * * * * * *function (
$treffer) {



** * * * * * * * * * * *
$aufruf $this->templateDir.''.$treffer[1].'.'.$treffer[2];


** * * * * * * * * * * *return 
file_get_contents($aufruf);
** * * * * * * * * *}, 
$this->template);


** * * *
// Kommentare löschen
** * * *#$this->template = preg_replace("/".$this->leftDelimiterC."(.*)".$this->rightDelimiterC."/isUe", "", $this->template);

** * * *return *true;


** *} 

Wäre über Tipps und Hilfestellung dankbar.

Viele Grüße
Mike
Mit Zitat antworten