tags:

views:

576

answers:

2

For those of you who don't know what's gonna happen in PHP6, here's a nice short read: http://jero.net/articles/php6

Now, if you have functions that depend on ereg and you don't have control over the php.ini file on the server that's hosting your scripts, how do you deal with that?

For instance, this function here:

function currentDateTime() {
  list($micro, $Unixtime) = explode(" ",microtime());
  $sec= $micro + date("s", $Unixtime);
  $sec = mb_ereg_replace(sprintf('%d', $sec), "", ($micro + date("s", $Unixtime)));
  return date("Y-m-d H:i:s", $Unixtime).$sec;
}

It seems to be dependant on ereg, so how do I replace this?

+8  A: 

You could re-write to use the preg functions.

Edit: dynamically loading seems to be deprecated...

Greg
+1 for mentioning preg functions... which have been recommended over ereg functions for years.
R. Bemrose
+1  A: 

You can use ini_set() to set PHP configuration values within your script in the event that you don't have control over your php.ini file. But I recommend trying to migrate to preg_ over ereg_ at some point. PCRE is much more useful and powerful than POSIX regular expressions, and are largely compatible.

Chris Lutz