Foros del Web » Programando para Internet » PHP »

preg_replace_callback in php5.3+

Estas en el tema de preg_replace_callback in php5.3+ en el foro de PHP en Foros del Web. HOla comunidad, tengo el siguiente código: Código: $this->page = preg_replace_callback('/{page_link_(.*?)}/is', create_function('$matches', 'global $config; require_once($config[\'basepath\'].\'/include/page_display.inc.php\'); $title = page_display::get_page_title($matches[1]); $title = strtolower(str_replace(" ", $config[\'seo_url_seperator\'], $title)); return $config[\'baseurl\'].\'/page-\'.urlencode($title).\'-\'.$matches[1].\'.html\';'), ...
  #1 (permalink)  
Antiguo 30/05/2017, 17:11
Avatar de xplorador  
Fecha de Ingreso: enero-2002
Ubicación: Peru
Mensajes: 105
Antigüedad: 22 años, 2 meses
Puntos: 0
Exclamación preg_replace_callback in php5.3+

HOla comunidad, tengo el siguiente código:
Código:
$this->page = preg_replace_callback('/{page_link_(.*?)}/is', create_function('$matches', 'global $config; 
require_once($config[\'basepath\'].\'/include/page_display.inc.php\'); 
$title = page_display::get_page_title($matches[1]); 
$title = strtolower(str_replace(" ", $config[\'seo_url_seperator\'], $title)); 
return $config[\'baseurl\'].\'/page-\'.urlencode($title).\'-\'.$matches[1].\'.html\';'), $this->page);
el cual me devuelve el siguiente error:

Cita:
Strict Standards: Non-static method page_display::get_page_title() should not be called statically in
Estado revisando y veo que hay una incompatibilidad de la función "preg_replace_callback" a partir de php5.3+ y que "create_function" hay que reemplazarlo por "function"

Intente así y no me funciona:
Código:
$this->page = preg_replace_callback('/{page_link_(.*?)}/is', 
function($matches) {global $config; 
require_once($config[\'basepath\'].\'/include/page_display.inc.php\'); 
$title = page_display::get_page_title($matches[1]); 
$title = strtolower(str_replace(" ", $config[\'seo_url_seperator\'], $title)); 
return $config[\'baseurl\'].\'/page-\'.urlencode($title).\'-\'.$matches[1].\'.html\';'}, $this->page);
Alguien puede orientarme en la sintaxis para que funcione en php5.3
__________________
Adictoshp.org
  #2 (permalink)  
Antiguo 31/05/2017, 11:39
 
Fecha de Ingreso: octubre-2009
Mensajes: 305
Antigüedad: 14 años, 5 meses
Puntos: 29
Respuesta: preg_replace_callback in php5.3+

el error es de POO que indica que dicho método no se puede llamar como estatico, debes invocarlo desde la instancia de la clase

Etiquetas: php+
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:17.