You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

In PHP 7.x, ereg functions are no longer supported. Based on my search on internet, ereg functions use a very limited regex flavor called POSIX ERE.

Below example shows the alternative method in preg functions

ereg functionsRecommended functions

ereg

$source = "My email address is ck@qsok.com";
if (ereg("email", $source)) {
  echo "the source has 'email' on the content";
}

preg_match

$source = "My email address is ck@qsok.com";
if (preg("/email/", $source)) {
  echo "the source has 'email' on the content";
}

eregi

$source = "My email address is ck@qsok.com";
if (eregi("chun kang", $source)) {
  echo "the source has 'chun kang' on the content";
}
preg_match
$source = "My email address is ck@qsok.com";
if (preg_match("/Chun Kang/i", $source)) {
  echo "the source has 'email' on the content";
}
  • No labels