Installing esotalk forum. Gives the message:

Deprecated: preg_replace (): The / e modifier is deprecated, use preg_replace_callback instead of /Applications/MAMP/htdocs/esotalk/core/lib/ETSQLQuery.class.php on line 666

Here is the function with 666 lines. Help replace the preg_replace () function with preg_replace_callback (). I do not understand how to do it.

public function get() { // Run the appropriate get function depending on this query's mode. switch ($this->mode) { case "select": $query = $this->getSelect(); break; case "update": $query = $this->getUpdate(); break; case "insert": $query = $this->getInsert(); break; case "replace": $query = $this->getReplace(); break; case "delete": $query = $this->getDelete(); break; case "union": $query = $this->getUnion(); break; default: $query = ""; } // Substitute in bound parameter values. $query = preg_replace('/(:[A-Za-z0-9_]+)/e', 'array_key_exists("$1", $this->parameters) ? ET::$database->escapeValue($this->parameters["$1"][0], $this->parameters["$1"][1]) : "$1"', $query); return $query; } 

    1 answer 1

    The modifier е deprecated; you must use preg_replace_callback , passing an anonymous callback function as the second argument:

     // Substitute in bound parameter values. $query = preg_replace_callback('/:[A-Za-z0-9_]+/', function($m) { return array_key_exists($m[0], $this->parameters) ? ET::$database->escapeValue($this->parameters[$m[0]][0], $this->parameters[$m[0]][1]) : $m[0]; }, $query); 

    Details :

    • e modifier removed
    • Callback function($m) {} : function($m) {}
    • The regular brackets '/:[A-Za-z0-9_]+/' removed the parentheses as unnecessary, since ...
    • $m[0] is an integer match.