Last Day I have installed wamp server 2.2 and I was using wamp server 2.0c till then. I have a strange problem,
when i start wampserver and try to load pages on browser it shows the error

Deprecated: Function ereg() is deprecated

Please help me , thanks in advance.

[ The error show for the ]

Dani AI

Generated

— short, practical checklist and examples to fix the libmail warning without guessing at causes. pointed toward using PCRE and flagged the compatibility issue; below are safe, testable steps plus examples you can apply to the library.

Start small: search the library for ereg, eregi, ereg_replace, eregi_replace. For each hit, convert to the PCRE equivalents and test that the pattern still matches. Key rules: PCRE needs delimiters (typically /), case-insensitive POSIX calls need the i modifier, and replacement/backreference syntax can differ — test each change.

Example conversions:

// POSIX-style -> PCRE
// original (POSIX): ereg("^From: (.*)$", $header, $m)
// converted (PCRE):
if (preg_match('/^From: (.*)$/', $header, $m)) {
    // ...
}

// case-insensitive POSIX -> PCRE with 'i'
if (preg_match('/pattern/i', $str)) {
    // ...
}

// ereg_replace -> preg_replace
$out = preg_replace('/pattern/', 'replacement', $in);

// if replacement requires PHP execution, use callback
$out = preg_replace_callback('/pattern/', function($matches){
    return strtoupper($matches[1]);
}, $in);

If you cannot update everything at once, temporarily suppress deprecation notices while you migrate:

error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE);

Use that only short-term. Suppressing hides problems and is not a real fix.

Migration tips:

  • Run the site on a local copy and use automated searches (grep, your editor) to find all occurrences.
  • After replacing, run any mail-related flows (send, parse headers) to verify behavior — regex differences can subtly change matches.
  • For large or complex POSIX expressions, convert and test incrementally. If a quick stopgap is needed, replace simple patterns first and leave complex ones for careful refactoring.
  • Consider switching the library to a maintained mail library (for example, a Composer package) if you find many compatibility issues.

This approach gives a safe path from the deprecation notice to a robust, tested conversion.

Recommended Answers

All 7 Replies

Try going through this forum.

I think it'll help

You'll need to use the preg_match() functions, and it's siblings.

yep it's deprecated in php 5.3.0
which php version do u have?

You'll need to use the preg_match() functions, and it's siblings.

the error found for a library function that i have copied

yep it's deprecated in php 5.3.0
which php version do u have?

php 5.3, and now i got the error was occured due to that.

yep it's deprecated in php 5.3.0
which php version do u have?

It i library file with more than 500 lines and a noob like me can not handle that :(

I got the solution as i need to use preg_match() instead of ereg() .

THank you for helping me. the thread status is swithcing to solved .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.