Hello to all.

I am trying to install one script, but it crashes:

Deprecated: Function ereg_replace() is deprecated. 

I understand you need to install the version of php 5.3 , but how to change this part of the code correctly?

 $template = ereg_replace("{([A-Z0-9_]+)}","",$template); if (ereg("^(http://|ftp://|mailto:).*$", $back)) $back = "/_admin/"; 
  • one
    Use the preg_replace and preg_match functions. The main difference is that inside the quotation marks, the regular schedule must be further enclosed in slashes. preg_replace("/{([A-Z0-9_]+)}/"....) - Mike
  • @Mike Please post your comment as a response. - Nicolas Chabanovsky

1 answer 1

The ereg_ * functions are obsolete, should be used instead:

 $template = preg_replace("/{([A-Z0-9_]+)}/","",$template); if (preg_match('#^(http://|ftp://|mailto:)#', $back)) $back = "/_admin/"; 

The difference of these functions in the regular expression dialect (PCRE instead of extended POSIX). In your case, both regulars remain unchanged. But in the new functions, the regular schedule additionally needs to be enclosed in some characters, usually in / or another character, if obliques are found in the regulator itself and are too lazy to escape them.