Page 1 of 1

Deprecated: Function ereg() is deprecated in php5.3

Posted: Wed Sep 02, 2009 10:37 pm
by Hphp
hi , Iam new in php, i run the test program

Code: Select all

<?php
   $url = "http://www.apress.com";
 
   // break $url down into three distinct pieces: 
   // "http://www", "apress", and "com"
   $parts = ereg("^(http://www)\.([[:alnum:]]+)\.([[:alnum:]]+)", $url, $regs);
 
   echo $regs[0];     // outputs the entire string "http://www.apress.com"
   echo "<br>";
   echo $regs[1];     // outputs "http://www"
   echo "<br>";
   echo $regs[2];     // outputs "apress"
   echo "<br>";
   echo $regs[3];     // outputs "com"
?>
the output is Deprecated: Function ereg() is deprecated in C:\wamp\www\Expressions\ereg.php on line 7
http://www.apress.com
http://www
apress
com
what is wrong?? :|

Re: Deprecated: Function ereg() is deprecated in php5.3

Posted: Wed Sep 02, 2009 10:42 pm
by requinix
What is wrong is that the test program is using stuff that it shouldn't anymore. As of PHP 5.3 you aren't supposed to use ereg functions so it will complain every time you do.

Find a different test program or tutorial, or learn about the PCRE library which you should be using instead.