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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Hphp
Forum Newbie
Posts: 6
Joined: Tue Sep 01, 2009 10:03 pm

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

Post 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?? :|
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post 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.
Post Reply