Error Deprecated: Function ereg ()

4

In script that I installed gave this error:

  

Deprecated: Function ereg () is deprecated in /home/u844214382/public_html/functions.php on line 98 Deprecated:

Code on line 98:

if (ereg("^[a-zA-Z0-9\-_]{3,20}$", $mensaje)) {

There are still other calls to ereg in the same file .

    
asked by anonymous 05.04.2014 / 00:27

2 answers

3

ereg_* was marked as obsolete ( deprecated ) in PHP 5.3. To fix this, just switch to preg_match . For example:

ereg("^[a-zA-Z0-9\-_]{3,20}$", $nombre_usuario)

Switch By:

 if (preg_match("/^[a-zA-Z0-9\-_]{3,20}$/", $nombre_usuario)){
      ----------^                       ^----------- 
 inicio do delimitador                   fim do delimitador

To correct your code you need to change the ereg in the functions:

  • ValidaMail ()
  • shout ()
  • uc ()
  • Basically what changes are you forced to put your regex between some delemiter, in case it was / . Another point is that ereg is based on the Unix regex while preg_* is in Perl (see PCRE modifiers ).

        
    05.04.2014 / 00:51
    1

    Your version of php is up to date and letting you know that ereg no longer works.

    You can replace with preg_match () which is an alternative.

        
    07.04.2014 / 03:13