Recently I saw a problem in a simple code:
$regexp = "^((http://)|(https://)|(mailto:)|(ftp://))?(([a-zA-Z0-9_.!~*'()-]|(%[0-9a-fA-F]{2})|[;&=+$,])+(:([a-zA-Z0-9_.!~*'()-]|(%[0-9a-fA-F]{2})|[;:&=+$,])+){0}@){0}((((((2(([0-4][0-9])|(5[0-5])))|([01]?[0-9]?[0-9]))\.){3}((2(([0-4][0-9])|(5[0-5])))|([01]?[0-9]?[0-9]))))|(([a-zA-Z0-9](([a-zA-Z0-9-]{0,62})[a-zA-Z0-9])?\.)*([a-zA-Z](([a-zA-Z0-9-]*)[a-zA-Z0-9])?)))?(:(([0-5]?[0-9]{1,4})|(6[0-4][0-9]{3})|(65[0-4][0-9]{2})|(655[0-2][0-9])|(6553[0-5])))?(/((;)?([a-zA-Z0-9_.!~*'()-]|(%[0-9a-fA-F]{2})|[:@&=+$,])+(/)?)*)?(\?([;/?:@&=+$,]|[a-zA-Z0-9_.!~*'()-]|(%[0-9a-fA-F]{2}))*)?(#([;/?:@&=+$,]|[a-zA-Z0-9_.!~*'()-]|(%[0-9a-fA-F]{2}))*)?$";
$urladdr = '89.221.92.122/api/xml';
$result = eregi($regexp, $urladdr);
wamp server returns true, while xampp server returns false! I know that eregi is deprecated, but right know I expect it to work fine in php 5.3.1
My Question
Is there any php or apache config caused this behavior?
A simple test file of the script is uploaded here: eregi on xampp + phpinfo
The above code in my wamp is here: eregi on wamp + phpinfo
I don't want you to solve my problem, I just want to know why this kind of problems happen.
It appears that the POSIX "extended regex" module/extension can either take advantage of native system support or use an implementation bundled with the PHP source. I haven't found any clear reference to this, but there are clues:
ext/ereg/php_regex.h
phpinfo()
output you posted includes the line "Bundled library enabled". (Incidentally, I came upon the source which outputs that: ext/ereg/ereg.c
line 238.This is actually quite common for many of the older parts of PHP, which were originally built on system libraries and APIs which can reliably be found on "POSIX-compliant" systems, and were later "ported" to other systems by reimplementing the required functionality. This causes some discrepancies between platforms, particularly on Windows, where most of the expected libraries will be missing.
Recent versions of PHP have tried to identify and rectify such inconsistencies - for instance, many of the filesystem-related functions used to have warnings of limited or incorrect behaviour under Windows, but now show these as fixed in a particular version. However, since this particular extension has been deprecated in favour of the cross-platform PCRE library, there has probably not been a great deal of testing of its different implementations, even before the official deprecation notice was added in PHP 5.3.