erm...i have a class, trying to make a template class, using preg_replace_callback, but i don't know how the parameter 2 write
class template {
public function parse_template($newtpl, $cachetpl){
......
$template = preg_replace("/\<\!\-\-\{(.+?)\}\-\-\>/s", "{\\1}", $template);
$template = preg_replace_callback("/\{lang\s+(.+?)\}/is", $this->languagevar('\\1'), $template);
......
}
public function languagevar($param1){
......
return $lang[$param1];
......
}
}
how this work?
at my html(template) file, have something like this {lang hello}, and the parse_template found the {lang anything} it will convert using $this->languagevar('hello');
but i keep getting error at the
$template = preg_replace_callback("/\{lang\s+(.+?)\}/is", $this->languagevar('\\1'), $template);
the error message was
preg_replace_callback(): Requires argument 2, '('\1')', to be a valid callback
before i can do the callback using
preg_replace("/\{lang\s+(.+?)\}/ies", "\$this->languagevar('\\1')", $template);
but maybe current php version problem, it got error say that /e is deprecated, use preg_replace_callback instead