summaryrefslogtreecommitdiff
path: root/ext/ereg
diff options
context:
space:
mode:
authorRobin Fernandes <robinf@php.net>2008-04-11 08:57:17 +0000
committerRobin Fernandes <robinf@php.net>2008-04-11 08:57:17 +0000
commitbcd9a07d6c6548764b6788fa15f6606d40085b51 (patch)
treebdb74db510a6f32eae1799cacde1ac4064512bed /ext/ereg
parent7b22726093ba554e616b45127bb238d5bd005007 (diff)
downloadphp-git-bcd9a07d6c6548764b6788fa15f6606d40085b51.tar.gz
Adding some tests for ereg and url functions.
Diffstat (limited to 'ext/ereg')
-rw-r--r--ext/ereg/tests/ereg_basic_001.phpt127
-rw-r--r--ext/ereg/tests/ereg_basic_002.phpt56
-rw-r--r--ext/ereg/tests/ereg_basic_003.phpt25
-rw-r--r--ext/ereg/tests/ereg_basic_004.phpt33
-rw-r--r--ext/ereg/tests/ereg_error_001.phpt45
-rw-r--r--ext/ereg/tests/ereg_error_002.phpt88
-rw-r--r--ext/ereg/tests/ereg_replace_basic_001.phpt60
-rw-r--r--ext/ereg/tests/ereg_replace_basic_002.phpt30
-rw-r--r--ext/ereg/tests/ereg_replace_error_001.phpt42
-rw-r--r--ext/ereg/tests/ereg_replace_error_002.phpt76
-rw-r--r--ext/ereg/tests/ereg_replace_variation_001.phpt175
-rw-r--r--ext/ereg/tests/ereg_replace_variation_002.phpt163
-rw-r--r--ext/ereg/tests/ereg_replace_variation_003.phpt169
-rw-r--r--ext/ereg/tests/ereg_variation_001.phpt178
-rw-r--r--ext/ereg/tests/ereg_variation_002.phpt169
-rw-r--r--ext/ereg/tests/ereg_variation_003.phpt283
-rw-r--r--ext/ereg/tests/ereg_variation_004.phpt18
-rw-r--r--ext/ereg/tests/eregi_basic.phpt41
-rw-r--r--ext/ereg/tests/eregi_basic_001.phpt127
-rw-r--r--ext/ereg/tests/eregi_basic_002.phpt56
-rw-r--r--ext/ereg/tests/eregi_basic_003.phpt25
-rw-r--r--ext/ereg/tests/eregi_basic_004.phpt31
-rw-r--r--ext/ereg/tests/eregi_error_001.phpt45
-rw-r--r--ext/ereg/tests/eregi_error_002.phpt88
-rw-r--r--ext/ereg/tests/eregi_replace_basic.phpt36
-rw-r--r--ext/ereg/tests/eregi_replace_basic_001.phpt60
-rw-r--r--ext/ereg/tests/eregi_replace_basic_002.phpt28
-rw-r--r--ext/ereg/tests/eregi_replace_error_001.phpt42
-rw-r--r--ext/ereg/tests/eregi_replace_error_002.phpt76
-rw-r--r--ext/ereg/tests/eregi_replace_variation_001.phpt175
-rw-r--r--ext/ereg/tests/eregi_replace_variation_002.phpt163
-rw-r--r--ext/ereg/tests/eregi_replace_variation_003.phpt169
-rw-r--r--ext/ereg/tests/eregi_variation_001.phpt178
-rw-r--r--ext/ereg/tests/eregi_variation_002.phpt169
-rw-r--r--ext/ereg/tests/eregi_variation_003.phpt283
-rw-r--r--ext/ereg/tests/eregi_variation_004.phpt18
-rw-r--r--ext/ereg/tests/regular_expressions.inc24
-rw-r--r--ext/ereg/tests/split_basic_001.phpt129
-rw-r--r--ext/ereg/tests/split_basic_002.phpt227
-rw-r--r--ext/ereg/tests/split_basic_003.phpt48
-rw-r--r--ext/ereg/tests/split_error_001.phpt41
-rw-r--r--ext/ereg/tests/split_error_002.phpt88
-rw-r--r--ext/ereg/tests/split_variation_001.phpt256
-rw-r--r--ext/ereg/tests/split_variation_002.phpt268
-rw-r--r--ext/ereg/tests/split_variation_003.phpt239
-rw-r--r--ext/ereg/tests/split_variation_004.phpt48
-rw-r--r--ext/ereg/tests/spliti_basic_001.phpt129
-rw-r--r--ext/ereg/tests/spliti_basic_002.phpt227
-rw-r--r--ext/ereg/tests/spliti_basic_003.phpt43
-rw-r--r--ext/ereg/tests/spliti_basic_004.phpt45
-rw-r--r--ext/ereg/tests/spliti_error_001.phpt41
-rw-r--r--ext/ereg/tests/spliti_error_002.phpt88
-rw-r--r--ext/ereg/tests/spliti_variation_001.phpt256
-rw-r--r--ext/ereg/tests/spliti_variation_002.phpt270
-rw-r--r--ext/ereg/tests/spliti_variation_003.phpt239
-rw-r--r--ext/ereg/tests/spliti_variation_004.phpt48
-rw-r--r--ext/ereg/tests/sql_regcase_basic_001.phpt25
-rw-r--r--ext/ereg/tests/sql_regcase_error_001.phpt37
-rw-r--r--ext/ereg/tests/sql_regcase_variation_001.phpt167
59 files changed, 6530 insertions, 0 deletions
diff --git a/ext/ereg/tests/ereg_basic_001.phpt b/ext/ereg/tests/ereg_basic_001.phpt
new file mode 100644
index 0000000000..485b2d26e8
--- /dev/null
+++ b/ext/ereg/tests/ereg_basic_001.phpt
@@ -0,0 +1,127 @@
+--TEST--
+Test ereg() function : basic functionality (with $regs)
+--FILE--
+<?php
+/* Prototype : proto int ereg(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test a number of simple, valid matches with ereg, specifying $regs
+ */
+
+echo "*** Testing ereg() : basic functionality ***\n";
+
+include(dirname(__FILE__) . '/regular_expressions.inc');
+
+foreach ($expressions as $re) {
+ list($pattern,$string) = $re;
+ echo "--> Pattern: '$pattern'; string: '$string'\n";
+ var_dump(ereg($pattern, $string, $regs));
+ var_dump($regs);
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg() : basic functionality ***
+--> Pattern: '..(a|b|c)(a|b|c)..'; string: '--- ab ---'
+int(6)
+array(3) {
+ [0]=>
+ string(6) "- ab -"
+ [1]=>
+ string(1) "a"
+ [2]=>
+ string(1) "b"
+}
+--> Pattern: '()'; string: ''
+int(1)
+array(2) {
+ [0]=>
+ bool(false)
+ [1]=>
+ bool(false)
+}
+--> Pattern: '()'; string: 'abcdef'
+int(1)
+array(2) {
+ [0]=>
+ bool(false)
+ [1]=>
+ bool(false)
+}
+--> Pattern: '[x]|[^x]'; string: 'abcdef'
+int(1)
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+--> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; string: '--- aaa bbb ccc ddd ---'
+int(15)
+array(6) {
+ [0]=>
+ string(15) "aaa bbb ccc ddd"
+ [1]=>
+ string(1) "a"
+ [2]=>
+ string(2) "aa"
+ [3]=>
+ string(3) "bbb"
+ [4]=>
+ string(3) "ccc"
+ [5]=>
+ string(3) "ddd"
+}
+--> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; string: '\`^.[$()|*+?{''
+int(14)
+array(1) {
+ [0]=>
+ string(14) "\`^.[$()|*+?{'"
+}
+--> Pattern: '\a'; string: 'a'
+int(1)
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+--> Pattern: '[0-9][^0-9]'; string: '2a'
+int(2)
+array(1) {
+ [0]=>
+ string(2) "2a"
+}
+--> Pattern: '^[[:alnum:]]{62,62}$'; string: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+int(62)
+array(1) {
+ [0]=>
+ string(62) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+}
+--> Pattern: '^[[:digit:]]{5}'; string: '0123456789'
+int(5)
+array(1) {
+ [0]=>
+ string(5) "01234"
+}
+--> Pattern: '[[:digit:]]{5}$'; string: '0123456789'
+int(5)
+array(1) {
+ [0]=>
+ string(5) "56789"
+}
+--> Pattern: '[[:blank:]]{1,10}'; string: '
+ '
+int(2)
+array(1) {
+ [0]=>
+ string(2) " "
+}
+--> Pattern: '[[:print:]]{3}'; string: ' a '
+int(3)
+array(1) {
+ [0]=>
+ string(3) " a "
+}
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/ereg_basic_002.phpt b/ext/ereg/tests/ereg_basic_002.phpt
new file mode 100644
index 0000000000..672632fc7d
--- /dev/null
+++ b/ext/ereg/tests/ereg_basic_002.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Test ereg() function : basic functionality (without $regs)
+--FILE--
+<?php
+/* Prototype : proto int ereg(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test a number of simple, valid matches with ereg, without specifying $regs
+ */
+
+echo "*** Testing ereg() : basic functionality ***\n";
+
+include(dirname(__FILE__) . '/regular_expressions.inc');
+
+foreach ($expressions as $re) {
+ list($pattern,$string) = $re;
+ echo "--> Pattern: '$pattern'; string: '$string'\n";
+ var_dump(ereg($pattern, $string));
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg() : basic functionality ***
+--> Pattern: '..(a|b|c)(a|b|c)..'; string: '--- ab ---'
+int(1)
+--> Pattern: '()'; string: ''
+int(1)
+--> Pattern: '()'; string: 'abcdef'
+int(1)
+--> Pattern: '[x]|[^x]'; string: 'abcdef'
+int(1)
+--> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; string: '--- aaa bbb ccc ddd ---'
+int(1)
+--> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; string: '\`^.[$()|*+?{''
+int(1)
+--> Pattern: '\a'; string: 'a'
+int(1)
+--> Pattern: '[0-9][^0-9]'; string: '2a'
+int(1)
+--> Pattern: '^[[:alnum:]]{62,62}$'; string: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+int(1)
+--> Pattern: '^[[:digit:]]{5}'; string: '0123456789'
+int(1)
+--> Pattern: '[[:digit:]]{5}$'; string: '0123456789'
+int(1)
+--> Pattern: '[[:blank:]]{1,10}'; string: '
+ '
+int(1)
+--> Pattern: '[[:print:]]{3}'; string: ' a '
+int(1)
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/ereg_basic_003.phpt b/ext/ereg/tests/ereg_basic_003.phpt
new file mode 100644
index 0000000000..8c14738832
--- /dev/null
+++ b/ext/ereg/tests/ereg_basic_003.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Test ereg() function : basic functionality - long RE
+--FILE--
+<?php
+/* Prototype : proto int ereg(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test a long RE with lots of matches
+ */
+
+var_dump(ereg(str_repeat('(.)', 2048), str_repeat('x', 2048)));
+var_dump(ereg(str_repeat('(.)', 2048), str_repeat('x', 2048), $regs));
+var_dump(count($regs));
+
+echo "Done";
+?>
+--EXPECTF--
+int(1)
+int(2048)
+int(2049)
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/ereg_basic_004.phpt b/ext/ereg/tests/ereg_basic_004.phpt
new file mode 100644
index 0000000000..1356eaf637
--- /dev/null
+++ b/ext/ereg/tests/ereg_basic_004.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test ereg() function : basic functionality - a few non-matches
+--FILE--
+<?php
+/* Prototype : proto int ereg(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+$regs = 'original';
+
+var_dump(ereg('A', 'a', $regs));
+var_dump(ereg('[A-Z]', '0', $regs));
+var_dump(ereg('(a){4}', 'aaa', $regs));
+var_dump(ereg('^a', 'ba', $regs));
+var_dump(ereg('b$', 'ba', $regs));
+var_dump(ereg('[:alpha:]', 'x', $regs));
+
+// Ensure $regs is unchanged
+var_dump($regs);
+
+echo "Done";
+?>
+--EXPECTF--
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+string(8) "original"
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/ereg_error_001.phpt b/ext/ereg/tests/ereg_error_001.phpt
new file mode 100644
index 0000000000..44bb1f9653
--- /dev/null
+++ b/ext/ereg/tests/ereg_error_001.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Test ereg() function : error conditions - wrong number of args
+--FILE--
+<?php
+/* Prototype : proto int ereg(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test wrong number of args
+ */
+
+echo "*** Testing ereg() : error conditions ***\n";
+
+
+//Test ereg with one more than the expected number of arguments
+echo "\n-- Testing ereg() function with more than expected no. of arguments --\n";
+$pattern = 'string_val';
+$string = 'string_val';
+$registers = array(1, 2);
+$extra_arg = 10;
+var_dump( ereg($pattern, $string, $registers, $extra_arg) );
+
+// Testing ereg with one less than the expected number of arguments
+echo "\n-- Testing ereg() function with less than expected no. of arguments --\n";
+$pattern = 'string_val';
+var_dump( ereg($pattern) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg() : error conditions ***
+
+-- Testing ereg() function with more than expected no. of arguments --
+
+Warning: Wrong parameter count for ereg() in %s on line 21
+NULL
+
+-- Testing ereg() function with less than expected no. of arguments --
+
+Warning: Wrong parameter count for ereg() in %s on line 26
+NULL
+Done
diff --git a/ext/ereg/tests/ereg_error_002.phpt b/ext/ereg/tests/ereg_error_002.phpt
new file mode 100644
index 0000000000..61166ee979
--- /dev/null
+++ b/ext/ereg/tests/ereg_error_002.phpt
@@ -0,0 +1,88 @@
+--TEST--
+Test ereg() function : error conditions - test bad regular expressions
+--FILE--
+<?php
+/* Prototype : proto int ereg(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test bad regular expressions
+ */
+
+echo "*** Testing ereg() : error conditions ***\n";
+
+$regs = 'original';
+
+var_dump(ereg("", "hello"));
+var_dump(ereg("c(d", "hello"));
+var_dump(ereg("a[b", "hello"));
+var_dump(ereg("c(d", "hello"));
+var_dump(ereg("*", "hello"));
+var_dump(ereg("+", "hello"));
+var_dump(ereg("?", "hello"));
+var_dump(ereg("(+?*)", "hello", $regs));
+var_dump(ereg("h{256}", "hello"));
+var_dump(ereg("h|", "hello"));
+var_dump(ereg("h{0}", "hello"));
+var_dump(ereg("h{2,1}", "hello"));
+var_dump(ereg('[a-c-e]', 'd'));
+var_dump(ereg('\\', 'x'));
+var_dump(ereg('([9-0])', '1', $regs));
+
+//ensure $regs unchanged
+var_dump($regs);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg() : error conditions ***
+
+Warning: ereg(): REG_EMPTY in %s on line 16
+bool(false)
+
+Warning: ereg(): REG_EPAREN in %s on line 17
+bool(false)
+
+Warning: ereg(): REG_EBRACK in %s on line 18
+bool(false)
+
+Warning: ereg(): REG_EPAREN in %s on line 19
+bool(false)
+
+Warning: ereg(): REG_BADRPT in %s on line 20
+bool(false)
+
+Warning: ereg(): REG_BADRPT in %s on line 21
+bool(false)
+
+Warning: ereg(): REG_BADRPT in %s on line 22
+bool(false)
+
+Warning: ereg(): REG_BADRPT in %s on line 23
+bool(false)
+
+Warning: ereg(): REG_BADBR in %s on line 24
+bool(false)
+
+Warning: ereg(): REG_EMPTY in %s on line 25
+bool(false)
+
+Warning: ereg(): REG_EMPTY in %s on line 26
+bool(false)
+
+Warning: ereg(): REG_BADBR in %s on line 27
+bool(false)
+
+Warning: ereg(): REG_ERANGE in %s on line 28
+bool(false)
+
+Warning: ereg(): REG_EESCAPE in %s on line 29
+bool(false)
+
+Warning: ereg(): REG_ERANGE in %s on line 30
+bool(false)
+string(8) "original"
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/ereg_replace_basic_001.phpt b/ext/ereg/tests/ereg_replace_basic_001.phpt
new file mode 100644
index 0000000000..e0a5dfb7b8
--- /dev/null
+++ b/ext/ereg/tests/ereg_replace_basic_001.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test ereg_replace() function : basic functionality
+--FILE--
+<?php
+/* Prototype : proto string ereg_replace(string pattern, string replacement, string string)
+ * Description: Replace regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test a number of simple, valid matches with ereg_replace
+ */
+
+echo "*** Testing ereg() : basic functionality ***\n";
+
+include(dirname(__FILE__) . '/regular_expressions.inc');
+
+$replacement = '[this is a replacement]';
+
+foreach ($expressions as $re) {
+ list($pattern, $match) = $re;
+ echo "--> Pattern: '$pattern'; match: '$match'\n";
+ var_dump(ereg_replace($pattern, $replacement, $match . ' this contains some matches ' . $match));
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg() : basic functionality ***
+--> Pattern: '..(a|b|c)(a|b|c)..'; match: '--- ab ---'
+string(82) "--[this is a replacement]-- this contains some matches --[this is a replacement]--"
+--> Pattern: '()'; match: ''
+string(695) "[this is a replacement] [this is a replacement]t[this is a replacement]h[this is a replacement]i[this is a replacement]s[this is a replacement] [this is a replacement]c[this is a replacement]o[this is a replacement]n[this is a replacement]t[this is a replacement]a[this is a replacement]i[this is a replacement]n[this is a replacement]s[this is a replacement] [this is a replacement]s[this is a replacement]o[this is a replacement]m[this is a replacement]e[this is a replacement] [this is a replacement]m[this is a replacement]a[this is a replacement]t[this is a replacement]c[this is a replacement]h[this is a replacement]e[this is a replacement]s[this is a replacement] [this is a replacement]"
+--> Pattern: '()'; match: 'abcdef'
+string(983) "[this is a replacement]a[this is a replacement]b[this is a replacement]c[this is a replacement]d[this is a replacement]e[this is a replacement]f[this is a replacement] [this is a replacement]t[this is a replacement]h[this is a replacement]i[this is a replacement]s[this is a replacement] [this is a replacement]c[this is a replacement]o[this is a replacement]n[this is a replacement]t[this is a replacement]a[this is a replacement]i[this is a replacement]n[this is a replacement]s[this is a replacement] [this is a replacement]s[this is a replacement]o[this is a replacement]m[this is a replacement]e[this is a replacement] [this is a replacement]m[this is a replacement]a[this is a replacement]t[this is a replacement]c[this is a replacement]h[this is a replacement]e[this is a replacement]s[this is a replacement] [this is a replacement]a[this is a replacement]b[this is a replacement]c[this is a replacement]d[this is a replacement]e[this is a replacement]f[this is a replacement]"
+--> Pattern: '[x]|[^x]'; match: 'abcdef'
+string(920) "[this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement]"
+--> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; match: '--- aaa bbb ccc ddd ---'
+string(90) "--- [this is a replacement] --- this contains some matches --- [this is a replacement] ---"
+--> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; match: '\`^.[$()|*+?{''
+string(74) "[this is a replacement] this contains some matches [this is a replacement]"
+--> Pattern: '\a'; match: 'a'
+string(118) "[this is a replacement] this cont[this is a replacement]ins some m[this is a replacement]tches [this is a replacement]"
+--> Pattern: '[0-9][^0-9]'; match: '2a'
+string(74) "[this is a replacement] this contains some matches [this is a replacement]"
+--> Pattern: '^[[:alnum:]]{62,62}$'; match: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+string(152) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ this contains some matches 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+--> Pattern: '^[[:digit:]]{5}'; match: '0123456789'
+string(66) "[this is a replacement]56789 this contains some matches 0123456789"
+--> Pattern: '[[:digit:]]{5}$'; match: '0123456789'
+string(66) "0123456789 this contains some matches 01234[this is a replacement]"
+--> Pattern: '[[:blank:]]{1,10}'; match: '
+ '
+string(163) "
+[this is a replacement]this[this is a replacement]contains[this is a replacement]some[this is a replacement]matches[this is a replacement]
+[this is a replacement]"
+--> Pattern: '[[:print:]]{3}'; match: ' a '
+string(254) "[this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement] "
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/ereg_replace_basic_002.phpt b/ext/ereg/tests/ereg_replace_basic_002.phpt
new file mode 100644
index 0000000000..4ef9c4109e
--- /dev/null
+++ b/ext/ereg/tests/ereg_replace_basic_002.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Test ereg_replace() function : basic functionality - a few non-matches
+--FILE--
+<?php
+/* Prototype : proto string ereg_replace(string pattern, string replacement, string string)
+ * Description: Replace regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+$replacement = 'r';
+
+var_dump(ereg_replace('A', $replacement, 'a'));
+var_dump(ereg_replace('[A-Z]', $replacement, '0'));
+var_dump(ereg_replace('(a){4}', $replacement, 'aaa'));
+var_dump(ereg_replace('^a', $replacement, 'ba'));
+var_dump(ereg_replace('b$', $replacement, 'ba'));
+var_dump(ereg_replace('[:alpha:]', $replacement, 'x'));
+
+
+echo "Done";
+?>
+--EXPECTF--
+string(1) "a"
+string(1) "0"
+string(3) "aaa"
+string(2) "ba"
+string(2) "ba"
+string(1) "x"
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/ereg_replace_error_001.phpt b/ext/ereg/tests/ereg_replace_error_001.phpt
new file mode 100644
index 0000000000..e6aedf47e2
--- /dev/null
+++ b/ext/ereg/tests/ereg_replace_error_001.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Test ereg_replace() function : error conditions - wrong number of args
+--FILE--
+<?php
+/* Prototype : proto string ereg_replace(string pattern, string replacement, string string)
+ * Description: Replace regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+echo "*** Testing ereg_replace() : error conditions ***\n";
+
+
+//Test ereg_replace with one more than the expected number of arguments
+echo "\n-- Testing ereg_replace() function with more than expected no. of arguments --\n";
+$pattern = 'string_val';
+$replacement = 'string_val';
+$string = 'string_val';
+$extra_arg = 10;
+var_dump( ereg_replace($pattern, $replacement, $string, $extra_arg) );
+
+// Testing ereg_replace with one less than the expected number of arguments
+echo "\n-- Testing ereg_replace() function with less than expected no. of arguments --\n";
+$pattern = 'string_val';
+$replacement = 'string_val';
+var_dump( ereg_replace($pattern, $replacement) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg_replace() : error conditions ***
+
+-- Testing ereg_replace() function with more than expected no. of arguments --
+
+Warning: Wrong parameter count for ereg_replace() in %s on line 17
+NULL
+
+-- Testing ereg_replace() function with less than expected no. of arguments --
+
+Warning: Wrong parameter count for ereg_replace() in %s on line 23
+NULL
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/ereg_replace_error_002.phpt b/ext/ereg/tests/ereg_replace_error_002.phpt
new file mode 100644
index 0000000000..6e7183c425
--- /dev/null
+++ b/ext/ereg/tests/ereg_replace_error_002.phpt
@@ -0,0 +1,76 @@
+--TEST--
+Test ereg_replace() function : error conditions - bad regular expressions
+--FILE--
+<?php
+/* Prototype : proto string ereg_replace(string pattern, string replacement, string string)
+ * Description: Replace regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+echo "*** Testing ereg_replace() : bad REs ***\n";
+var_dump(ereg_replace("", "hello", "some string"));
+var_dump(ereg_replace("c(d", "hello", "some string"));
+var_dump(ereg_replace("a[b", "hello", "some string"));
+var_dump(ereg_replace("c(d", "hello", "some string"));;
+var_dump(ereg_replace("*", "hello", "some string"));
+var_dump(ereg_replace("+", "hello", "some string"));
+var_dump(ereg_replace("?", "hello", "some string"));
+var_dump(ereg_replace("(+?*)", "hello", "some string"));
+var_dump(ereg_replace("h{256}", "hello", "some string"));
+var_dump(ereg_replace("h|", "hello", "some string"));
+var_dump(ereg_replace("h{0}", "hello", "some string"));
+var_dump(ereg_replace("h{2,1}", "hello", "some string"));
+var_dump(ereg_replace('[a-c-e]', 'd', "some string"));
+var_dump(ereg_replace('\\', 'x', "some string"));
+var_dump(ereg_replace('([9-0])', '1', "some string"));
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg_replace() : bad REs ***
+
+Warning: ereg_replace(): REG_EMPTY in %s on line 9
+bool(false)
+
+Warning: ereg_replace(): REG_EPAREN in %s on line 10
+bool(false)
+
+Warning: ereg_replace(): REG_EBRACK in %s on line 11
+bool(false)
+
+Warning: ereg_replace(): REG_EPAREN in %s on line 12
+bool(false)
+
+Warning: ereg_replace(): REG_BADRPT in %s on line 13
+bool(false)
+
+Warning: ereg_replace(): REG_BADRPT in %s on line 14
+bool(false)
+
+Warning: ereg_replace(): REG_BADRPT in %s on line 15
+bool(false)
+
+Warning: ereg_replace(): REG_BADRPT in %s on line 16
+bool(false)
+
+Warning: ereg_replace(): REG_BADBR in %s on line 17
+bool(false)
+
+Warning: ereg_replace(): REG_EMPTY in %s on line 18
+bool(false)
+
+Warning: ereg_replace(): REG_EMPTY in %s on line 19
+bool(false)
+
+Warning: ereg_replace(): REG_BADBR in %s on line 20
+bool(false)
+
+Warning: ereg_replace(): REG_ERANGE in %s on line 21
+bool(false)
+
+Warning: ereg_replace(): REG_EESCAPE in %s on line 22
+bool(false)
+
+Warning: ereg_replace(): REG_ERANGE in %s on line 23
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/ereg_replace_variation_001.phpt b/ext/ereg/tests/ereg_replace_variation_001.phpt
new file mode 100644
index 0000000000..446ac86e03
--- /dev/null
+++ b/ext/ereg/tests/ereg_replace_variation_001.phpt
@@ -0,0 +1,175 @@
+--TEST--
+Test ereg_replace() function : usage variations - unexpected type arg 1
+--FILE--
+<?php
+/* Prototype : proto string ereg_replace(string pattern, string replacement, string string)
+ * Description: Replace regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing ereg_replace() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$replacement = 'new';
+$string = 'original';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for pattern
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( ereg_replace($value, $replacement, $string) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg_replace() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(64)
+Error: 8 - Undefined variable: unset_var, %s(67)
+
+Arg value 0
+Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value 1
+string(8) "original"
+
+Arg value 12345
+string(8) "original"
+
+Arg value -2345
+string(8) "original"
+
+Arg value 10.5
+string(8) "original"
+
+Arg value -10.5
+string(8) "original"
+
+Arg value 101234567000
+string(8) "original"
+
+Arg value 1.07654321E-9
+Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value 0.5
+Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value Array
+Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value Array
+string(8) "original"
+
+Arg value Array
+string(8) "original"
+
+Arg value Array
+string(8) "original"
+
+Arg value Array
+string(8) "original"
+
+Arg value
+Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value
+Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value 1
+string(8) "original"
+
+Arg value
+Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value 1
+string(8) "original"
+
+Arg value
+Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value
+Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value
+Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
+bool(false)
+Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
+
+Arg value
+Error: 8 - Object of class stdClass could not be converted to int, %s(74)
+string(8) "original"
+
+Arg value
+Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value
+Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/ereg_replace_variation_002.phpt b/ext/ereg/tests/ereg_replace_variation_002.phpt
new file mode 100644
index 0000000000..16a4d5614b
--- /dev/null
+++ b/ext/ereg/tests/ereg_replace_variation_002.phpt
@@ -0,0 +1,163 @@
+--TEST--
+Test ereg_replace() function : usage variations - unexpected type arg 2
+--FILE--
+<?php
+/* Prototype : proto string ereg_replace(string pattern, string replacement, string string)
+ * Description: Replace regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing ereg_replace() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$pattern = 'ell';
+$string = 'hello!';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for replacement
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump(urlencode(ereg_replace($pattern, $value, $string)));
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg_replace() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(64)
+Error: 8 - Undefined variable: unset_var, %s(67)
+
+Arg value 0
+string(5) "ho%21"
+
+Arg value 1
+string(8) "h%01o%21"
+
+Arg value 12345
+string(6) "h9o%21"
+
+Arg value -2345
+string(8) "h%D7o%21"
+
+Arg value 10.5
+string(8) "h%0Ao%21"
+
+Arg value -10.5
+string(8) "h%F6o%21"
+
+Arg value 101234567000
+string(8) "h%FFo%21"
+
+Arg value 1.07654321E-9
+string(5) "ho%21"
+
+Arg value 0.5
+string(5) "ho%21"
+
+Arg value Array
+string(5) "ho%21"
+
+Arg value Array
+string(8) "h%01o%21"
+
+Arg value Array
+string(8) "h%01o%21"
+
+Arg value Array
+string(8) "h%01o%21"
+
+Arg value Array
+string(8) "h%01o%21"
+
+Arg value
+string(5) "ho%21"
+
+Arg value
+string(5) "ho%21"
+
+Arg value 1
+string(8) "h%01o%21"
+
+Arg value
+string(5) "ho%21"
+
+Arg value 1
+string(8) "h%01o%21"
+
+Arg value
+string(5) "ho%21"
+
+Arg value
+string(5) "ho%21"
+
+Arg value
+string(5) "ho%21"
+Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
+
+Arg value
+Error: 8 - Object of class stdClass could not be converted to int, %s(74)
+string(8) "h%01o%21"
+
+Arg value
+string(5) "ho%21"
+
+Arg value
+string(5) "ho%21"
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/ereg_replace_variation_003.phpt b/ext/ereg/tests/ereg_replace_variation_003.phpt
new file mode 100644
index 0000000000..1d83535996
--- /dev/null
+++ b/ext/ereg/tests/ereg_replace_variation_003.phpt
@@ -0,0 +1,169 @@
+--TEST--
+Test ereg_replace() function : usage variations - unexpected type arg 3
+--FILE--
+<?php
+/* Prototype : proto string ereg_replace(string pattern, string replacement, string string)
+ * Description: Replace regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing ereg_replace() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$pattern = '1';
+$replacement = 'new value';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for string
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( ereg_replace($pattern, $replacement, $value) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg_replace() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(64)
+Error: 8 - Undefined variable: unset_var, %s(67)
+
+Arg value 0
+string(1) "0"
+
+Arg value 1
+string(9) "new value"
+
+Arg value 12345
+string(13) "new value2345"
+
+Arg value -2345
+string(5) "-2345"
+
+Arg value 10.5
+string(12) "new value0.5"
+
+Arg value -10.5
+string(13) "-new value0.5"
+
+Arg value 101234567000
+string(28) "new value0new value234567000"
+
+Arg value 1.07654321E-9
+string(29) "new value.0765432new valueE-9"
+
+Arg value 0.5
+string(3) "0.5"
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+string(5) "Array"
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+string(5) "Array"
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+string(5) "Array"
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+string(5) "Array"
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+string(5) "Array"
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+
+Arg value 1
+string(9) "new value"
+
+Arg value
+string(0) ""
+
+Arg value 1
+string(9) "new value"
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
+
+Arg value
+Error: 4096 - Object of class stdClass could not be converted to string, %s(74)
+Error: 8 - Object of class stdClass to string conversion, %s(74)
+string(6) "Object"
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/ereg_variation_001.phpt b/ext/ereg/tests/ereg_variation_001.phpt
new file mode 100644
index 0000000000..977404d054
--- /dev/null
+++ b/ext/ereg/tests/ereg_variation_001.phpt
@@ -0,0 +1,178 @@
+--TEST--
+Test ereg() function : usage variations - unexpected type arg 1
+--FILE--
+<?php
+/* Prototype : proto int ereg(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+
+echo "*** Testing ereg() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$string = '1';
+$registers = array(1, 2);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for pattern
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( ereg($value, $string, $registers) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(65)
+Error: 8 - Undefined variable: unset_var, %s(68)
+
+Arg value 0
+bool(false)
+
+Arg value 1
+int(1)
+
+Arg value 12345
+bool(false)
+
+Arg value -2345
+bool(false)
+
+Arg value 10.5
+bool(false)
+
+Arg value -10.5
+bool(false)
+
+Arg value 101234567000
+bool(false)
+
+Arg value 1.07654321E-9
+bool(false)
+
+Arg value 0.5
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(75)
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(75)
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(75)
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(75)
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(75)
+bool(false)
+
+Arg value
+Error: 2 - ereg(): REG_EMPTY, %s(75)
+bool(false)
+
+Arg value
+Error: 2 - ereg(): REG_EMPTY, %s(75)
+bool(false)
+
+Arg value 1
+int(1)
+
+Arg value
+Error: 2 - ereg(): REG_EMPTY, %s(75)
+bool(false)
+
+Arg value 1
+int(1)
+
+Arg value
+Error: 2 - ereg(): REG_EMPTY, %s(75)
+bool(false)
+
+Arg value
+Error: 2 - ereg(): REG_EMPTY, %s(75)
+bool(false)
+
+Arg value
+Error: 2 - ereg(): REG_EMPTY, %s(75)
+bool(false)
+Error: 4096 - Object of class stdClass could not be converted to string, %s(74)
+
+Arg value
+Error: 4096 - Object of class stdClass could not be converted to string, %s(75)
+Error: 8 - Object of class stdClass to string conversion, %s(75)
+bool(false)
+
+Arg value
+Error: 2 - ereg(): REG_EMPTY, %s(75)
+bool(false)
+
+Arg value
+Error: 2 - ereg(): REG_EMPTY, %s(75)
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/ereg_variation_002.phpt b/ext/ereg/tests/ereg_variation_002.phpt
new file mode 100644
index 0000000000..c5f4e8e016
--- /dev/null
+++ b/ext/ereg/tests/ereg_variation_002.phpt
@@ -0,0 +1,169 @@
+--TEST--
+Test ereg() function : usage variations - unexpected type arg 2
+--FILE--
+<?php
+/* Prototype : proto int ereg(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing ereg() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$pattern = '1';
+$registers = array();
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for string
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( ereg($pattern, $value, $registers) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(64)
+Error: 8 - Undefined variable: unset_var, %s(67)
+
+Arg value 0
+bool(false)
+
+Arg value 1
+int(1)
+
+Arg value 12345
+int(1)
+
+Arg value -2345
+bool(false)
+
+Arg value 10.5
+int(1)
+
+Arg value -10.5
+int(1)
+
+Arg value 101234567000
+int(1)
+
+Arg value 1.07654321E-9
+int(1)
+
+Arg value 0.5
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+bool(false)
+
+Arg value
+bool(false)
+
+Arg value
+bool(false)
+
+Arg value 1
+int(1)
+
+Arg value
+bool(false)
+
+Arg value 1
+int(1)
+
+Arg value
+bool(false)
+
+Arg value
+bool(false)
+
+Arg value
+bool(false)
+Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
+
+Arg value
+Error: 4096 - Object of class stdClass could not be converted to string, %s(74)
+Error: 8 - Object of class stdClass to string conversion, %s(74)
+bool(false)
+
+Arg value
+bool(false)
+
+Arg value
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/ereg_variation_003.phpt b/ext/ereg/tests/ereg_variation_003.phpt
new file mode 100644
index 0000000000..42c1ae1bb1
--- /dev/null
+++ b/ext/ereg/tests/ereg_variation_003.phpt
@@ -0,0 +1,283 @@
+--TEST--
+Test ereg() function : usage variations - unexpected type for arg 3
+--FILE--
+<?php
+/* Prototype : proto int ereg(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing ereg() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$pattern = 'h(.*)lo!';
+$string = 'hello!';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for registers
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( ereg($pattern, $string, $value) );
+ var_dump($value);
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(61)
+Error: 8 - Undefined variable: unset_var, %s(64)
+
+Arg value 0
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value 1
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value 12345
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value -2345
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value 10.5
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value -10.5
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value 101234567000
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value 1.07654321E-9
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value 0.5
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value 1
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value 1
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value string
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value string
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+Error: 4096 - Object of class stdClass could not be converted to string, %s(70)
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/ereg_variation_004.phpt b/ext/ereg/tests/ereg_variation_004.phpt
new file mode 100644
index 0000000000..cbbb3c15e6
--- /dev/null
+++ b/ext/ereg/tests/ereg_variation_004.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Test ereg() function : usage variations - pass non-variable as arg 3, which is pass-by-ref.
+--FILE--
+<?php
+/* Prototype : proto int ereg(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+var_dump(ereg('l{2}', 'hello', str_repeat('x',1)));
+echo "Done";
+?>
+--EXPECTF--
+
+Strict Standards: Only variables should be passed by reference in %s on line 8
+int(2)
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_basic.phpt b/ext/ereg/tests/eregi_basic.phpt
new file mode 100644
index 0000000000..de1db0ed46
--- /dev/null
+++ b/ext/ereg/tests/eregi_basic.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Test eregi() function : basic functionality - confirm case insensitivity
+--FILE--
+<?php
+/* Prototype : proto int eregi(string pattern, string string [, array registers])
+ * Description: Case-insensitive regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test basic funtionality of eregi()
+ */
+
+echo "*** Testing eregi() : basic functionality ***\n";
+$string = <<<END
+UPPERCASE WORDS
+lowercase words
+MIxED CaSe woRdS
+END;
+
+var_dump(eregi('words', $string, $match1));
+var_dump($match1);
+
+var_dump(eregi('[[:lower:]]+[[:space:]]case', $string, $match2)); //character class lower should just match [a-z] but in case insensitive search matches [a-zA-Z]
+var_dump($match2);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing eregi() : basic functionality ***
+int(5)
+array(1) {
+ [0]=>
+ string(5) "WORDS"
+}
+int(10)
+array(1) {
+ [0]=>
+ string(10) "MIxED CaSe"
+}
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_basic_001.phpt b/ext/ereg/tests/eregi_basic_001.phpt
new file mode 100644
index 0000000000..8557b8111d
--- /dev/null
+++ b/ext/ereg/tests/eregi_basic_001.phpt
@@ -0,0 +1,127 @@
+--TEST--
+Test eregi() function : basic functionality (with $regs)
+--FILE--
+<?php
+/* Prototype : proto int eregi(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test a number of simple, valid matches with eregi, specifying $regs
+ */
+
+echo "*** Testing eregi() : basic functionality ***\n";
+
+include(dirname(__FILE__) . '/regular_expressions.inc');
+
+foreach ($expressions as $re) {
+ list($pattern,$string) = $re;
+ echo "--> Pattern: '$pattern'; string: '$string'\n";
+ var_dump(eregi($pattern, $string, $regs));
+ var_dump($regs);
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing eregi() : basic functionality ***
+--> Pattern: '..(a|b|c)(a|b|c)..'; string: '--- ab ---'
+int(6)
+array(3) {
+ [0]=>
+ string(6) "- ab -"
+ [1]=>
+ string(1) "a"
+ [2]=>
+ string(1) "b"
+}
+--> Pattern: '()'; string: ''
+int(1)
+array(2) {
+ [0]=>
+ bool(false)
+ [1]=>
+ bool(false)
+}
+--> Pattern: '()'; string: 'abcdef'
+int(1)
+array(2) {
+ [0]=>
+ bool(false)
+ [1]=>
+ bool(false)
+}
+--> Pattern: '[x]|[^x]'; string: 'abcdef'
+int(1)
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+--> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; string: '--- aaa bbb ccc ddd ---'
+int(15)
+array(6) {
+ [0]=>
+ string(15) "aaa bbb ccc ddd"
+ [1]=>
+ string(1) "a"
+ [2]=>
+ string(2) "aa"
+ [3]=>
+ string(3) "bbb"
+ [4]=>
+ string(3) "ccc"
+ [5]=>
+ string(3) "ddd"
+}
+--> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; string: '\`^.[$()|*+?{''
+int(14)
+array(1) {
+ [0]=>
+ string(14) "\`^.[$()|*+?{'"
+}
+--> Pattern: '\a'; string: 'a'
+int(1)
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+--> Pattern: '[0-9][^0-9]'; string: '2a'
+int(2)
+array(1) {
+ [0]=>
+ string(2) "2a"
+}
+--> Pattern: '^[[:alnum:]]{62,62}$'; string: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+int(62)
+array(1) {
+ [0]=>
+ string(62) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+}
+--> Pattern: '^[[:digit:]]{5}'; string: '0123456789'
+int(5)
+array(1) {
+ [0]=>
+ string(5) "01234"
+}
+--> Pattern: '[[:digit:]]{5}$'; string: '0123456789'
+int(5)
+array(1) {
+ [0]=>
+ string(5) "56789"
+}
+--> Pattern: '[[:blank:]]{1,10}'; string: '
+ '
+int(2)
+array(1) {
+ [0]=>
+ string(2) " "
+}
+--> Pattern: '[[:print:]]{3}'; string: ' a '
+int(3)
+array(1) {
+ [0]=>
+ string(3) " a "
+}
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_basic_002.phpt b/ext/ereg/tests/eregi_basic_002.phpt
new file mode 100644
index 0000000000..8c5d0e471e
--- /dev/null
+++ b/ext/ereg/tests/eregi_basic_002.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Test eregi() function : basic functionality (without $regs)
+--FILE--
+<?php
+/* Prototype : proto int eregi(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test a number of simple, valid matches with eregi, without specifying $regs
+ */
+
+echo "*** Testing eregi() : basic functionality ***\n";
+
+include(dirname(__FILE__) . '/regular_expressions.inc');
+
+foreach ($expressions as $re) {
+ list($pattern,$string) = $re;
+ echo "--> Pattern: '$pattern'; string: '$string'\n";
+ var_dump(eregi($pattern, $string));
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing eregi() : basic functionality ***
+--> Pattern: '..(a|b|c)(a|b|c)..'; string: '--- ab ---'
+int(1)
+--> Pattern: '()'; string: ''
+int(1)
+--> Pattern: '()'; string: 'abcdef'
+int(1)
+--> Pattern: '[x]|[^x]'; string: 'abcdef'
+int(1)
+--> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; string: '--- aaa bbb ccc ddd ---'
+int(1)
+--> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; string: '\`^.[$()|*+?{''
+int(1)
+--> Pattern: '\a'; string: 'a'
+int(1)
+--> Pattern: '[0-9][^0-9]'; string: '2a'
+int(1)
+--> Pattern: '^[[:alnum:]]{62,62}$'; string: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+int(1)
+--> Pattern: '^[[:digit:]]{5}'; string: '0123456789'
+int(1)
+--> Pattern: '[[:digit:]]{5}$'; string: '0123456789'
+int(1)
+--> Pattern: '[[:blank:]]{1,10}'; string: '
+ '
+int(1)
+--> Pattern: '[[:print:]]{3}'; string: ' a '
+int(1)
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_basic_003.phpt b/ext/ereg/tests/eregi_basic_003.phpt
new file mode 100644
index 0000000000..a4861caa83
--- /dev/null
+++ b/ext/ereg/tests/eregi_basic_003.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Test eregi() function : basic functionality - long RE
+--FILE--
+<?php
+/* Prototype : proto int eregi(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test a long RE with lots of matches
+ */
+
+var_dump(eregi(str_repeat('(.)', 2048), str_repeat('x', 2048)));
+var_dump(eregi(str_repeat('(.)', 2048), str_repeat('x', 2048), $regs));
+var_dump(count($regs));
+
+echo "Done";
+?>
+--EXPECTF--
+int(1)
+int(2048)
+int(2049)
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_basic_004.phpt b/ext/ereg/tests/eregi_basic_004.phpt
new file mode 100644
index 0000000000..ad411e21f5
--- /dev/null
+++ b/ext/ereg/tests/eregi_basic_004.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test eregi() function : basic functionality - a few non-matches
+--FILE--
+<?php
+/* Prototype : proto int eregi(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+$regs = 'original';
+
+var_dump(eregi('[A-Z]', '0', $regs));
+var_dump(eregi('(a){4}', 'aaa', $regs));
+var_dump(eregi('^a', 'ba', $regs));
+var_dump(eregi('b$', 'ba', $regs));
+var_dump(eregi('[:alpha:]', 'x', $regs));
+
+// Ensure $regs is unchanged
+var_dump($regs);
+
+echo "Done";
+?>
+--EXPECTF--
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+string(8) "original"
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_error_001.phpt b/ext/ereg/tests/eregi_error_001.phpt
new file mode 100644
index 0000000000..a767e24b59
--- /dev/null
+++ b/ext/ereg/tests/eregi_error_001.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Test eregi() function : error conditions - wrong number of args
+--FILE--
+<?php
+/* Prototype : proto int eregi(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test wrong number of args
+ */
+
+echo "*** Testing eregi() : error conditions ***\n";
+
+
+//Test eregi with one more than the expected number of arguments
+echo "\n-- Testing eregi() function with more than expected no. of arguments --\n";
+$pattern = 'string_val';
+$string = 'string_val';
+$registers = array(1, 2);
+$extra_arg = 10;
+var_dump( eregi($pattern, $string, $registers, $extra_arg) );
+
+// Testing eregi with one less than the expected number of arguments
+echo "\n-- Testing eregi() function with less than expected no. of arguments --\n";
+$pattern = 'string_val';
+var_dump( eregi($pattern) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing eregi() : error conditions ***
+
+-- Testing eregi() function with more than expected no. of arguments --
+
+Warning: Wrong parameter count for eregi() in %s on line 21
+NULL
+
+-- Testing eregi() function with less than expected no. of arguments --
+
+Warning: Wrong parameter count for eregi() in %s on line 26
+NULL
+Done
diff --git a/ext/ereg/tests/eregi_error_002.phpt b/ext/ereg/tests/eregi_error_002.phpt
new file mode 100644
index 0000000000..3c3bd7c992
--- /dev/null
+++ b/ext/ereg/tests/eregi_error_002.phpt
@@ -0,0 +1,88 @@
+--TEST--
+Test eregi() function : error conditions - test bad regular expressions
+--FILE--
+<?php
+/* Prototype : proto int eregi(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test bad regular expressions
+ */
+
+echo "*** Testing eregi() : error conditions ***\n";
+
+$regs = 'original';
+
+var_dump(eregi("", "hello"));
+var_dump(eregi("c(d", "hello"));
+var_dump(eregi("a[b", "hello"));
+var_dump(eregi("c(d", "hello"));
+var_dump(eregi("*", "hello"));
+var_dump(eregi("+", "hello"));
+var_dump(eregi("?", "hello"));
+var_dump(eregi("(+?*)", "hello", $regs));
+var_dump(eregi("h{256}", "hello"));
+var_dump(eregi("h|", "hello"));
+var_dump(eregi("h{0}", "hello"));
+var_dump(eregi("h{2,1}", "hello"));
+var_dump(eregi('[a-c-e]', 'd'));
+var_dump(eregi('\\', 'x'));
+var_dump(eregi('([9-0])', '1', $regs));
+
+//ensure $regs unchanged
+var_dump($regs);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing eregi() : error conditions ***
+
+Warning: eregi(): REG_EMPTY in %s on line 16
+bool(false)
+
+Warning: eregi(): REG_EPAREN in %s on line 17
+bool(false)
+
+Warning: eregi(): REG_EBRACK in %s on line 18
+bool(false)
+
+Warning: eregi(): REG_EPAREN in %s on line 19
+bool(false)
+
+Warning: eregi(): REG_BADRPT in %s on line 20
+bool(false)
+
+Warning: eregi(): REG_BADRPT in %s on line 21
+bool(false)
+
+Warning: eregi(): REG_BADRPT in %s on line 22
+bool(false)
+
+Warning: eregi(): REG_BADRPT in %s on line 23
+bool(false)
+
+Warning: eregi(): REG_BADBR in %s on line 24
+bool(false)
+
+Warning: eregi(): REG_EMPTY in %s on line 25
+bool(false)
+
+Warning: eregi(): REG_EMPTY in %s on line 26
+bool(false)
+
+Warning: eregi(): REG_BADBR in %s on line 27
+bool(false)
+
+Warning: eregi(): REG_ERANGE in %s on line 28
+bool(false)
+
+Warning: eregi(): REG_EESCAPE in %s on line 29
+bool(false)
+
+Warning: eregi(): REG_ERANGE in %s on line 30
+bool(false)
+string(8) "original"
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_replace_basic.phpt b/ext/ereg/tests/eregi_replace_basic.phpt
new file mode 100644
index 0000000000..f9f025fe98
--- /dev/null
+++ b/ext/ereg/tests/eregi_replace_basic.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Test eregi_replace() function : basic functionality - confirm case insensitivity
+--FILE--
+
+<?php
+/* Prototype : proto string eregi_replace(string pattern, string replacement, string string)
+ * Description: Case insensitive replace regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test basic functionality of eregi_replace()
+ */
+
+echo "*** Testing eregi_replace() : basic functionality ***\n";
+
+$string = 'UPPERCASE WORDS, lowercase words, MIxED CaSe woRdS';
+
+echo "String Before...\n";
+var_dump($string);
+echo "\nString after...\n";
+
+var_dump(eregi_replace('([[:lower:]]+) word', '\\1_character', $string));
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing eregi_replace() : basic functionality ***
+String Before...
+string(50) "UPPERCASE WORDS, lowercase words, MIxED CaSe woRdS"
+
+String after...
+string(65) "UPPERCASE_characterS, lowercase_characters, MIxED CaSe_characterS"
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_replace_basic_001.phpt b/ext/ereg/tests/eregi_replace_basic_001.phpt
new file mode 100644
index 0000000000..bffcd06377
--- /dev/null
+++ b/ext/ereg/tests/eregi_replace_basic_001.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test ereg() function : basic functionality
+--FILE--
+<?php
+/* Prototype : proto string eregi_replace(string pattern, string replacement, string string)
+ * Description: Replace regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test a number of simple, valid matches with eregi_replace
+ */
+
+echo "*** Testing ereg() : basic functionality ***\n";
+
+include(dirname(__FILE__) . '/regular_expressions.inc');
+
+$replacement = '[this is a replacement]';
+
+foreach ($expressions as $re) {
+ list($pattern, $match) = $re;
+ echo "--> Pattern: '$pattern'; match: '$match'\n";
+ var_dump(eregi_replace($pattern, $replacement, $match . ' this contains some matches ' . $match));
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg() : basic functionality ***
+--> Pattern: '..(a|b|c)(a|b|c)..'; match: '--- ab ---'
+string(82) "--[this is a replacement]-- this contains some matches --[this is a replacement]--"
+--> Pattern: '()'; match: ''
+string(695) "[this is a replacement] [this is a replacement]t[this is a replacement]h[this is a replacement]i[this is a replacement]s[this is a replacement] [this is a replacement]c[this is a replacement]o[this is a replacement]n[this is a replacement]t[this is a replacement]a[this is a replacement]i[this is a replacement]n[this is a replacement]s[this is a replacement] [this is a replacement]s[this is a replacement]o[this is a replacement]m[this is a replacement]e[this is a replacement] [this is a replacement]m[this is a replacement]a[this is a replacement]t[this is a replacement]c[this is a replacement]h[this is a replacement]e[this is a replacement]s[this is a replacement] [this is a replacement]"
+--> Pattern: '()'; match: 'abcdef'
+string(983) "[this is a replacement]a[this is a replacement]b[this is a replacement]c[this is a replacement]d[this is a replacement]e[this is a replacement]f[this is a replacement] [this is a replacement]t[this is a replacement]h[this is a replacement]i[this is a replacement]s[this is a replacement] [this is a replacement]c[this is a replacement]o[this is a replacement]n[this is a replacement]t[this is a replacement]a[this is a replacement]i[this is a replacement]n[this is a replacement]s[this is a replacement] [this is a replacement]s[this is a replacement]o[this is a replacement]m[this is a replacement]e[this is a replacement] [this is a replacement]m[this is a replacement]a[this is a replacement]t[this is a replacement]c[this is a replacement]h[this is a replacement]e[this is a replacement]s[this is a replacement] [this is a replacement]a[this is a replacement]b[this is a replacement]c[this is a replacement]d[this is a replacement]e[this is a replacement]f[this is a replacement]"
+--> Pattern: '[x]|[^x]'; match: 'abcdef'
+string(920) "[this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement]"
+--> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; match: '--- aaa bbb ccc ddd ---'
+string(90) "--- [this is a replacement] --- this contains some matches --- [this is a replacement] ---"
+--> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; match: '\`^.[$()|*+?{''
+string(74) "[this is a replacement] this contains some matches [this is a replacement]"
+--> Pattern: '\a'; match: 'a'
+string(118) "[this is a replacement] this cont[this is a replacement]ins some m[this is a replacement]tches [this is a replacement]"
+--> Pattern: '[0-9][^0-9]'; match: '2a'
+string(74) "[this is a replacement] this contains some matches [this is a replacement]"
+--> Pattern: '^[[:alnum:]]{62,62}$'; match: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+string(152) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ this contains some matches 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+--> Pattern: '^[[:digit:]]{5}'; match: '0123456789'
+string(66) "[this is a replacement]56789 this contains some matches 0123456789"
+--> Pattern: '[[:digit:]]{5}$'; match: '0123456789'
+string(66) "0123456789 this contains some matches 01234[this is a replacement]"
+--> Pattern: '[[:blank:]]{1,10}'; match: '
+ '
+string(163) "
+[this is a replacement]this[this is a replacement]contains[this is a replacement]some[this is a replacement]matches[this is a replacement]
+[this is a replacement]"
+--> Pattern: '[[:print:]]{3}'; match: ' a '
+string(254) "[this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement] "
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_replace_basic_002.phpt b/ext/ereg/tests/eregi_replace_basic_002.phpt
new file mode 100644
index 0000000000..7a4bd3d841
--- /dev/null
+++ b/ext/ereg/tests/eregi_replace_basic_002.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Test eregi_replace() function : basic functionality - a few non-matches
+--FILE--
+<?php
+/* Prototype : proto string eregi_replace(string pattern, string replacement, string string)
+ * Description: Replace regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+$replacement = 'r';
+
+var_dump(eregi_replace('[A-Z]', $replacement, '0'));
+var_dump(eregi_replace('(a){4}', $replacement, 'aaa'));
+var_dump(eregi_replace('^a', $replacement, 'ba'));
+var_dump(eregi_replace('b$', $replacement, 'ba'));
+var_dump(eregi_replace('[:alpha:]', $replacement, 'x'));
+
+
+echo "Done";
+?>
+--EXPECTF--
+string(1) "0"
+string(3) "aaa"
+string(2) "ba"
+string(2) "ba"
+string(1) "x"
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_replace_error_001.phpt b/ext/ereg/tests/eregi_replace_error_001.phpt
new file mode 100644
index 0000000000..8b7f90d9ad
--- /dev/null
+++ b/ext/ereg/tests/eregi_replace_error_001.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Test eregi_replace() function : error conditions - wrong number of args
+--FILE--
+<?php
+/* Prototype : proto string eregi_replace(string pattern, string replacement, string string)
+ * Description: Replace regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+echo "*** Testing eregi_replace() : error conditions ***\n";
+
+
+//Test eregi_replace with one more than the expected number of arguments
+echo "\n-- Testing eregi_replace() function with more than expected no. of arguments --\n";
+$pattern = 'string_val';
+$replacement = 'string_val';
+$string = 'string_val';
+$extra_arg = 10;
+var_dump( eregi_replace($pattern, $replacement, $string, $extra_arg) );
+
+// Testing eregi_replace with one less than the expected number of arguments
+echo "\n-- Testing eregi_replace() function with less than expected no. of arguments --\n";
+$pattern = 'string_val';
+$replacement = 'string_val';
+var_dump( eregi_replace($pattern, $replacement) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing eregi_replace() : error conditions ***
+
+-- Testing eregi_replace() function with more than expected no. of arguments --
+
+Warning: Wrong parameter count for eregi_replace() in %s on line 17
+NULL
+
+-- Testing eregi_replace() function with less than expected no. of arguments --
+
+Warning: Wrong parameter count for eregi_replace() in %s on line 23
+NULL
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_replace_error_002.phpt b/ext/ereg/tests/eregi_replace_error_002.phpt
new file mode 100644
index 0000000000..35684b8bde
--- /dev/null
+++ b/ext/ereg/tests/eregi_replace_error_002.phpt
@@ -0,0 +1,76 @@
+--TEST--
+Test eregi_replace() function : error conditions - bad regular expressions
+--FILE--
+<?php
+/* Prototype : proto string eregi_replace(string pattern, string replacement, string string)
+ * Description: Replace regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+echo "*** Testing eregi_replace() : bad REs ***\n";
+var_dump(eregi_replace("", "hello", "some string"));
+var_dump(eregi_replace("c(d", "hello", "some string"));
+var_dump(eregi_replace("a[b", "hello", "some string"));
+var_dump(eregi_replace("c(d", "hello", "some string"));;
+var_dump(eregi_replace("*", "hello", "some string"));
+var_dump(eregi_replace("+", "hello", "some string"));
+var_dump(eregi_replace("?", "hello", "some string"));
+var_dump(eregi_replace("(+?*)", "hello", "some string"));
+var_dump(eregi_replace("h{256}", "hello", "some string"));
+var_dump(eregi_replace("h|", "hello", "some string"));
+var_dump(eregi_replace("h{0}", "hello", "some string"));
+var_dump(eregi_replace("h{2,1}", "hello", "some string"));
+var_dump(eregi_replace('[a-c-e]', 'd', "some string"));
+var_dump(eregi_replace('\\', 'x', "some string"));
+var_dump(eregi_replace('([9-0])', '1', "some string"));
+echo "Done";
+?>
+--EXPECTF--
+*** Testing eregi_replace() : bad REs ***
+
+Warning: eregi_replace(): REG_EMPTY in %s on line 9
+bool(false)
+
+Warning: eregi_replace(): REG_EPAREN in %s on line 10
+bool(false)
+
+Warning: eregi_replace(): REG_EBRACK in %s on line 11
+bool(false)
+
+Warning: eregi_replace(): REG_EPAREN in %s on line 12
+bool(false)
+
+Warning: eregi_replace(): REG_BADRPT in %s on line 13
+bool(false)
+
+Warning: eregi_replace(): REG_BADRPT in %s on line 14
+bool(false)
+
+Warning: eregi_replace(): REG_BADRPT in %s on line 15
+bool(false)
+
+Warning: eregi_replace(): REG_BADRPT in %s on line 16
+bool(false)
+
+Warning: eregi_replace(): REG_BADBR in %s on line 17
+bool(false)
+
+Warning: eregi_replace(): REG_EMPTY in %s on line 18
+bool(false)
+
+Warning: eregi_replace(): REG_EMPTY in %s on line 19
+bool(false)
+
+Warning: eregi_replace(): REG_BADBR in %s on line 20
+bool(false)
+
+Warning: eregi_replace(): REG_ERANGE in %s on line 21
+bool(false)
+
+Warning: eregi_replace(): REG_EESCAPE in %s on line 22
+bool(false)
+
+Warning: eregi_replace(): REG_ERANGE in %s on line 23
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_replace_variation_001.phpt b/ext/ereg/tests/eregi_replace_variation_001.phpt
new file mode 100644
index 0000000000..87f9aa277c
--- /dev/null
+++ b/ext/ereg/tests/eregi_replace_variation_001.phpt
@@ -0,0 +1,175 @@
+--TEST--
+Test eregi_replace() function : usage variations - unexpected type arg 1
+--FILE--
+<?php
+/* Prototype : proto string eregi_replace(string pattern, string replacement, string string)
+ * Description: Replace regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing eregi_replace() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$replacement = 'new';
+$string = 'original';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for pattern
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( eregi_replace($value, $replacement, $string) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing eregi_replace() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(64)
+Error: 8 - Undefined variable: unset_var, %s(67)
+
+Arg value 0
+Error: 2 - eregi_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value 1
+string(8) "original"
+
+Arg value 12345
+string(8) "original"
+
+Arg value -2345
+string(8) "original"
+
+Arg value 10.5
+string(8) "original"
+
+Arg value -10.5
+string(8) "original"
+
+Arg value 101234567000
+string(8) "original"
+
+Arg value 1.07654321E-9
+Error: 2 - eregi_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value 0.5
+Error: 2 - eregi_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value Array
+Error: 2 - eregi_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value Array
+string(8) "original"
+
+Arg value Array
+string(8) "original"
+
+Arg value Array
+string(8) "original"
+
+Arg value Array
+string(8) "original"
+
+Arg value
+Error: 2 - eregi_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value
+Error: 2 - eregi_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value 1
+string(8) "original"
+
+Arg value
+Error: 2 - eregi_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value 1
+string(8) "original"
+
+Arg value
+Error: 2 - eregi_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value
+Error: 2 - eregi_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value
+Error: 2 - eregi_replace(): REG_EMPTY, %s(74)
+bool(false)
+Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
+
+Arg value
+Error: 8 - Object of class stdClass could not be converted to int, %s(74)
+string(8) "original"
+
+Arg value
+Error: 2 - eregi_replace(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value
+Error: 2 - eregi_replace(): REG_EMPTY, %s(74)
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_replace_variation_002.phpt b/ext/ereg/tests/eregi_replace_variation_002.phpt
new file mode 100644
index 0000000000..ed4fb4cd4b
--- /dev/null
+++ b/ext/ereg/tests/eregi_replace_variation_002.phpt
@@ -0,0 +1,163 @@
+--TEST--
+Test eregi_replace() function : usage variations - unexpected type arg 2
+--FILE--
+<?php
+/* Prototype : proto string eregi_replace(string pattern, string replacement, string string)
+ * Description: Replace regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing eregi_replace() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$pattern = 'ell';
+$string = 'hello!';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for replacement
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump(urlencode(eregi_replace($pattern, $value, $string)));
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing eregi_replace() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(64)
+Error: 8 - Undefined variable: unset_var, %s(67)
+
+Arg value 0
+string(5) "ho%21"
+
+Arg value 1
+string(8) "h%01o%21"
+
+Arg value 12345
+string(6) "h9o%21"
+
+Arg value -2345
+string(8) "h%D7o%21"
+
+Arg value 10.5
+string(8) "h%0Ao%21"
+
+Arg value -10.5
+string(8) "h%F6o%21"
+
+Arg value 101234567000
+string(8) "h%FFo%21"
+
+Arg value 1.07654321E-9
+string(5) "ho%21"
+
+Arg value 0.5
+string(5) "ho%21"
+
+Arg value Array
+string(5) "ho%21"
+
+Arg value Array
+string(8) "h%01o%21"
+
+Arg value Array
+string(8) "h%01o%21"
+
+Arg value Array
+string(8) "h%01o%21"
+
+Arg value Array
+string(8) "h%01o%21"
+
+Arg value
+string(5) "ho%21"
+
+Arg value
+string(5) "ho%21"
+
+Arg value 1
+string(8) "h%01o%21"
+
+Arg value
+string(5) "ho%21"
+
+Arg value 1
+string(8) "h%01o%21"
+
+Arg value
+string(5) "ho%21"
+
+Arg value
+string(5) "ho%21"
+
+Arg value
+string(5) "ho%21"
+Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
+
+Arg value
+Error: 8 - Object of class stdClass could not be converted to int, %s(74)
+string(8) "h%01o%21"
+
+Arg value
+string(5) "ho%21"
+
+Arg value
+string(5) "ho%21"
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_replace_variation_003.phpt b/ext/ereg/tests/eregi_replace_variation_003.phpt
new file mode 100644
index 0000000000..f4426fd3cd
--- /dev/null
+++ b/ext/ereg/tests/eregi_replace_variation_003.phpt
@@ -0,0 +1,169 @@
+--TEST--
+Test eregi_replace() function : usage variations - unexpected type arg 3
+--FILE--
+<?php
+/* Prototype : proto string eregi_replace(string pattern, string replacement, string string)
+ * Description: Replace regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing eregi_replace() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$pattern = '1';
+$replacement = 'new value';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for string
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( eregi_replace($pattern, $replacement, $value) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing eregi_replace() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(64)
+Error: 8 - Undefined variable: unset_var, %s(67)
+
+Arg value 0
+string(1) "0"
+
+Arg value 1
+string(9) "new value"
+
+Arg value 12345
+string(13) "new value2345"
+
+Arg value -2345
+string(5) "-2345"
+
+Arg value 10.5
+string(12) "new value0.5"
+
+Arg value -10.5
+string(13) "-new value0.5"
+
+Arg value 101234567000
+string(28) "new value0new value234567000"
+
+Arg value 1.07654321E-9
+string(29) "new value.0765432new valueE-9"
+
+Arg value 0.5
+string(3) "0.5"
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+string(5) "Array"
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+string(5) "Array"
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+string(5) "Array"
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+string(5) "Array"
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+string(5) "Array"
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+
+Arg value 1
+string(9) "new value"
+
+Arg value
+string(0) ""
+
+Arg value 1
+string(9) "new value"
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
+
+Arg value
+Error: 4096 - Object of class stdClass could not be converted to string, %s(74)
+Error: 8 - Object of class stdClass to string conversion, %s(74)
+string(6) "Object"
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_variation_001.phpt b/ext/ereg/tests/eregi_variation_001.phpt
new file mode 100644
index 0000000000..ea8b8440dc
--- /dev/null
+++ b/ext/ereg/tests/eregi_variation_001.phpt
@@ -0,0 +1,178 @@
+--TEST--
+Test eregi() function : usage variations - unexpected type arg 1
+--FILE--
+<?php
+/* Prototype : proto int eregi(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+
+echo "*** Testing eregi() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$string = '1';
+$registers = array(1, 2);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for pattern
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( eregi($value, $string, $registers) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing eregi() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(65)
+Error: 8 - Undefined variable: unset_var, %s(68)
+
+Arg value 0
+bool(false)
+
+Arg value 1
+int(1)
+
+Arg value 12345
+bool(false)
+
+Arg value -2345
+bool(false)
+
+Arg value 10.5
+bool(false)
+
+Arg value -10.5
+bool(false)
+
+Arg value 101234567000
+bool(false)
+
+Arg value 1.07654321E-9
+bool(false)
+
+Arg value 0.5
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(75)
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(75)
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(75)
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(75)
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(75)
+bool(false)
+
+Arg value
+Error: 2 - eregi(): REG_EMPTY, %s(75)
+bool(false)
+
+Arg value
+Error: 2 - eregi(): REG_EMPTY, %s(75)
+bool(false)
+
+Arg value 1
+int(1)
+
+Arg value
+Error: 2 - eregi(): REG_EMPTY, %s(75)
+bool(false)
+
+Arg value 1
+int(1)
+
+Arg value
+Error: 2 - eregi(): REG_EMPTY, %s(75)
+bool(false)
+
+Arg value
+Error: 2 - eregi(): REG_EMPTY, %s(75)
+bool(false)
+
+Arg value
+Error: 2 - eregi(): REG_EMPTY, %s(75)
+bool(false)
+Error: 4096 - Object of class stdClass could not be converted to string, %s(74)
+
+Arg value
+Error: 4096 - Object of class stdClass could not be converted to string, %s(75)
+Error: 8 - Object of class stdClass to string conversion, %s(75)
+bool(false)
+
+Arg value
+Error: 2 - eregi(): REG_EMPTY, %s(75)
+bool(false)
+
+Arg value
+Error: 2 - eregi(): REG_EMPTY, %s(75)
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_variation_002.phpt b/ext/ereg/tests/eregi_variation_002.phpt
new file mode 100644
index 0000000000..766a48abd3
--- /dev/null
+++ b/ext/ereg/tests/eregi_variation_002.phpt
@@ -0,0 +1,169 @@
+--TEST--
+Test eregi() function : usage variations - unexpected type arg 2
+--FILE--
+<?php
+/* Prototype : proto int eregi(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing eregi() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$pattern = '1';
+$registers = array();
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for string
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( eregi($pattern, $value, $registers) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing eregi() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(64)
+Error: 8 - Undefined variable: unset_var, %s(67)
+
+Arg value 0
+bool(false)
+
+Arg value 1
+int(1)
+
+Arg value 12345
+int(1)
+
+Arg value -2345
+bool(false)
+
+Arg value 10.5
+int(1)
+
+Arg value -10.5
+int(1)
+
+Arg value 101234567000
+int(1)
+
+Arg value 1.07654321E-9
+int(1)
+
+Arg value 0.5
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+bool(false)
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+bool(false)
+
+Arg value
+bool(false)
+
+Arg value
+bool(false)
+
+Arg value 1
+int(1)
+
+Arg value
+bool(false)
+
+Arg value 1
+int(1)
+
+Arg value
+bool(false)
+
+Arg value
+bool(false)
+
+Arg value
+bool(false)
+Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
+
+Arg value
+Error: 4096 - Object of class stdClass could not be converted to string, %s(74)
+Error: 8 - Object of class stdClass to string conversion, %s(74)
+bool(false)
+
+Arg value
+bool(false)
+
+Arg value
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_variation_003.phpt b/ext/ereg/tests/eregi_variation_003.phpt
new file mode 100644
index 0000000000..43785871a9
--- /dev/null
+++ b/ext/ereg/tests/eregi_variation_003.phpt
@@ -0,0 +1,283 @@
+--TEST--
+Test eregi() function : usage variations - unexpected type for arg 3
+--FILE--
+<?php
+/* Prototype : proto int eregi(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing eregi() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$pattern = 'h(.*)lo!';
+$string = 'hello!';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for registers
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( eregi($pattern, $string, $value) );
+ var_dump($value);
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing eregi() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(61)
+Error: 8 - Undefined variable: unset_var, %s(64)
+
+Arg value 0
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value 1
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value 12345
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value -2345
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value 10.5
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value -10.5
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value 101234567000
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value 1.07654321E-9
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value 0.5
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value 1
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value 1
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value string
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value string
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+Error: 4096 - Object of class stdClass could not be converted to string, %s(70)
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+
+Arg value
+int(6)
+array(2) {
+ [0]=>
+ string(6) "hello!"
+ [1]=>
+ string(2) "el"
+}
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/eregi_variation_004.phpt b/ext/ereg/tests/eregi_variation_004.phpt
new file mode 100644
index 0000000000..bf4f036950
--- /dev/null
+++ b/ext/ereg/tests/eregi_variation_004.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Test eregi() function : usage variations - pass non-variable as arg 3, which is pass-by-ref.
+--FILE--
+<?php
+/* Prototype : proto int eregi(string pattern, string string [, array registers])
+ * Description: Regular expression match
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+var_dump(eregi('l{2}', 'hello', str_repeat('x',1)));
+echo "Done";
+?>
+--EXPECTF--
+
+Strict Standards: Only variables should be passed by reference in %s on line 8
+int(2)
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/regular_expressions.inc b/ext/ereg/tests/regular_expressions.inc
new file mode 100644
index 0000000000..98fae4b112
--- /dev/null
+++ b/ext/ereg/tests/regular_expressions.inc
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * POSIX regular expressions each coupled with a string that they match,
+ * based on documentation on http://www.tin.org/bin/man.cgi?section=7&topic=regex .
+ */
+$expressions = array(
+ //array(pattern, string to match)
+ array('..(a|b|c)(a|b|c)..', '--- ab ---'),
+ array('()', ''),
+ array('()', 'abcdef'),
+ array('[x]|[^x]', 'abcdef'),
+ array('(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)', '--- aaa bbb ccc ddd ---'),
+ array('\\\\\`\^\.\[\$\(\)\|\*\+\?\{\\\'', '\\`^.[$()|*+?{\''),
+ array('\\a', 'a'),
+ array('[0-9][^0-9]', '2a'),
+ array('^[[:alnum:]]{62,62}$', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'),
+ array('^[[:digit:]]{5}', '0123456789'),
+ array('[[:digit:]]{5}$', '0123456789'),
+ array('[[:blank:]]{1,10}', "\n \t"),
+ array('[[:print:]]{3}', " a "),
+);
+
+?> \ No newline at end of file
diff --git a/ext/ereg/tests/split_basic_001.phpt b/ext/ereg/tests/split_basic_001.phpt
new file mode 100644
index 0000000000..4be40c0860
--- /dev/null
+++ b/ext/ereg/tests/split_basic_001.phpt
@@ -0,0 +1,129 @@
+--TEST--
+Test split() function : basic functionality - test a number of simple split, specifying a limit
+--FILE--
+<?php
+/* Prototype : proto array split(string pattern, string string [, int limit])
+ * Description: Split string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test a number of simple split, specifying a limit
+ */
+
+echo "*** Testing ereg() : basic functionality ***\n";
+
+include(dirname(__FILE__) . '/regular_expressions.inc');
+
+foreach ($expressions as $re) {
+ list($pattern,$string) = $re;
+ echo "\n--> Pattern: '$pattern'; match: '$string'\n";
+ var_dump(split($pattern, $string . ' |1| ' . $string . ' |2| ' . $string, 2));
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg() : basic functionality ***
+
+--> Pattern: '..(a|b|c)(a|b|c)..'; match: '--- ab ---'
+array(2) {
+ [0]=>
+ string(2) "--"
+ [1]=>
+ string(32) "-- |1| --- ab --- |2| --- ab ---"
+}
+
+--> Pattern: '()'; match: ''
+
+Warning: split(): Invalid Regular Expression to split() in %s on line 19
+bool(false)
+
+--> Pattern: '()'; match: 'abcdef'
+
+Warning: split(): Invalid Regular Expression to split() in %s on line 19
+bool(false)
+
+--> Pattern: '[x]|[^x]'; match: 'abcdef'
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(27) "bcdef |1| abcdef |2| abcdef"
+}
+
+--> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; match: '--- aaa bbb ccc ddd ---'
+array(2) {
+ [0]=>
+ string(4) "--- "
+ [1]=>
+ string(60) " --- |1| --- aaa bbb ccc ddd --- |2| --- aaa bbb ccc ddd ---"
+}
+
+--> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; match: '\`^.[$()|*+?{''
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(38) " |1| \`^.[$()|*+?{' |2| \`^.[$()|*+?{'"
+}
+
+--> Pattern: '\a'; match: 'a'
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(12) " |1| a |2| a"
+}
+
+--> Pattern: '[0-9][^0-9]'; match: '2a'
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(14) " |1| 2a |2| 2a"
+}
+
+--> Pattern: '^[[:alnum:]]{62,62}$'; match: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+array(1) {
+ [0]=>
+ string(196) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |1| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |2| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+}
+
+--> Pattern: '^[[:digit:]]{5}'; match: '0123456789'
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(35) "56789 |1| 0123456789 |2| 0123456789"
+}
+
+--> Pattern: '[[:digit:]]{5}$'; match: '0123456789'
+array(2) {
+ [0]=>
+ string(35) "0123456789 |1| 0123456789 |2| 01234"
+ [1]=>
+ string(0) ""
+}
+
+--> Pattern: '[[:blank:]]{1,10}'; match: '
+ '
+array(2) {
+ [0]=>
+ string(1) "
+"
+ [1]=>
+ string(15) "|1|
+ |2|
+ "
+}
+
+--> Pattern: '[[:print:]]{3}'; match: ' a '
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(16) " |1| a |2| a "
+}
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/split_basic_002.phpt b/ext/ereg/tests/split_basic_002.phpt
new file mode 100644
index 0000000000..f0d17ef1d6
--- /dev/null
+++ b/ext/ereg/tests/split_basic_002.phpt
@@ -0,0 +1,227 @@
+--TEST--
+Test split() function : basic functionality - test a number of simple split, without specifying a limit
+--FILE--
+<?php
+/* Prototype : proto array split(string pattern, string string [, int limit])
+ * Description: Split string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test a number of simple split, without specifying a limit
+ */
+
+echo "*** Testing ereg() : basic functionality ***\n";
+
+include(dirname(__FILE__) . '/regular_expressions.inc');
+
+foreach ($expressions as $re) {
+ list($pattern,$string) = $re;
+ echo "\n--> Pattern: '$pattern'; match: '$string'\n";
+ var_dump(split($pattern, $string . ' |1| ' . $string . ' |2| ' . $string));
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg() : basic functionality ***
+
+--> Pattern: '..(a|b|c)(a|b|c)..'; match: '--- ab ---'
+array(4) {
+ [0]=>
+ string(2) "--"
+ [1]=>
+ string(9) "-- |1| --"
+ [2]=>
+ string(9) "-- |2| --"
+ [3]=>
+ string(2) "--"
+}
+
+--> Pattern: '()'; match: ''
+
+Warning: split(): Invalid Regular Expression to split() in %s on line 19
+bool(false)
+
+--> Pattern: '()'; match: 'abcdef'
+
+Warning: split(): Invalid Regular Expression to split() in %s on line 19
+bool(false)
+
+--> Pattern: '[x]|[^x]'; match: 'abcdef'
+array(29) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(0) ""
+ [8]=>
+ string(0) ""
+ [9]=>
+ string(0) ""
+ [10]=>
+ string(0) ""
+ [11]=>
+ string(0) ""
+ [12]=>
+ string(0) ""
+ [13]=>
+ string(0) ""
+ [14]=>
+ string(0) ""
+ [15]=>
+ string(0) ""
+ [16]=>
+ string(0) ""
+ [17]=>
+ string(0) ""
+ [18]=>
+ string(0) ""
+ [19]=>
+ string(0) ""
+ [20]=>
+ string(0) ""
+ [21]=>
+ string(0) ""
+ [22]=>
+ string(0) ""
+ [23]=>
+ string(0) ""
+ [24]=>
+ string(0) ""
+ [25]=>
+ string(0) ""
+ [26]=>
+ string(0) ""
+ [27]=>
+ string(0) ""
+ [28]=>
+ string(0) ""
+}
+
+--> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; match: '--- aaa bbb ccc ddd ---'
+array(4) {
+ [0]=>
+ string(4) "--- "
+ [1]=>
+ string(13) " --- |1| --- "
+ [2]=>
+ string(13) " --- |2| --- "
+ [3]=>
+ string(4) " ---"
+}
+
+--> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; match: '\`^.[$()|*+?{''
+array(4) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) " |1| "
+ [2]=>
+ string(5) " |2| "
+ [3]=>
+ string(0) ""
+}
+
+--> Pattern: '\a'; match: 'a'
+array(4) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) " |1| "
+ [2]=>
+ string(5) " |2| "
+ [3]=>
+ string(0) ""
+}
+
+--> Pattern: '[0-9][^0-9]'; match: '2a'
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(2) " |"
+ [2]=>
+ string(1) " "
+ [3]=>
+ string(2) " |"
+ [4]=>
+ string(1) " "
+ [5]=>
+ string(0) ""
+}
+
+--> Pattern: '^[[:alnum:]]{62,62}$'; match: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+array(1) {
+ [0]=>
+ string(196) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |1| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |2| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+}
+
+--> Pattern: '^[[:digit:]]{5}'; match: '0123456789'
+array(3) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(30) " |1| 0123456789 |2| 0123456789"
+}
+
+--> Pattern: '[[:digit:]]{5}$'; match: '0123456789'
+array(2) {
+ [0]=>
+ string(35) "0123456789 |1| 0123456789 |2| 01234"
+ [1]=>
+ string(0) ""
+}
+
+--> Pattern: '[[:blank:]]{1,10}'; match: '
+ '
+array(6) {
+ [0]=>
+ string(1) "
+"
+ [1]=>
+ string(3) "|1|"
+ [2]=>
+ string(1) "
+"
+ [3]=>
+ string(3) "|2|"
+ [4]=>
+ string(1) "
+"
+ [5]=>
+ string(0) ""
+}
+
+--> Pattern: '[[:print:]]{3}'; match: ' a '
+array(7) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(1) " "
+}
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/split_basic_003.phpt b/ext/ereg/tests/split_basic_003.phpt
new file mode 100644
index 0000000000..4d36fcddb3
--- /dev/null
+++ b/ext/ereg/tests/split_basic_003.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test split() function : basic functionality - a few non-matches
+--FILE--
+<?php
+/* Prototype : proto array split(string pattern, string string [, int limit])
+ * Description: split string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+$replacement = 'r';
+
+var_dump(split('A', '-- a --'));
+var_dump(split('[A-Z]', '-- 0 --'));
+var_dump(split('(a){4}', '--- aaa ---'));
+var_dump(split('^a', '--- ba ---'));
+var_dump(split('b$', '--- ba ---'));
+var_dump(split('[:alpha:]', '--- x ---'));
+
+
+echo "Done";
+?>
+--EXPECTF--
+array(1) {
+ [0]=>
+ string(7) "-- a --"
+}
+array(1) {
+ [0]=>
+ string(7) "-- 0 --"
+}
+array(1) {
+ [0]=>
+ string(11) "--- aaa ---"
+}
+array(1) {
+ [0]=>
+ string(10) "--- ba ---"
+}
+array(1) {
+ [0]=>
+ string(10) "--- ba ---"
+}
+array(1) {
+ [0]=>
+ string(9) "--- x ---"
+}
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/split_error_001.phpt b/ext/ereg/tests/split_error_001.phpt
new file mode 100644
index 0000000000..ff8e6cbdd1
--- /dev/null
+++ b/ext/ereg/tests/split_error_001.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Test split() function : error conditions - wrong number of args
+--FILE--
+<?php
+/* Prototype : proto array split(string pattern, string string [, int limit])
+ * Description: Split string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+echo "*** Testing split() : error conditions - wrong number of args ***\n";
+
+
+//Test split with one more than the expected number of arguments
+echo "\n-- Testing split() function with more than expected no. of arguments --\n";
+$pattern = 'string_val';
+$string = 'string_val';
+$limit = 10;
+$extra_arg = 10;
+var_dump( split($pattern, $string, $limit, $extra_arg) );
+
+// Testing split with one less than the expected number of arguments
+echo "\n-- Testing split() function with less than expected no. of arguments --\n";
+$pattern = 'string_val';
+var_dump( split($pattern) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing split() : error conditions - wrong number of args ***
+
+-- Testing split() function with more than expected no. of arguments --
+
+Warning: Wrong parameter count for split() in %s on line 17
+NULL
+
+-- Testing split() function with less than expected no. of arguments --
+
+Warning: Wrong parameter count for split() in %s on line 22
+NULL
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/split_error_002.phpt b/ext/ereg/tests/split_error_002.phpt
new file mode 100644
index 0000000000..8c4ce345d1
--- /dev/null
+++ b/ext/ereg/tests/split_error_002.phpt
@@ -0,0 +1,88 @@
+--TEST--
+Test split() function : error conditions - test bad regular expressions
+--FILE--
+<?php
+/* Prototype : proto array split(string pattern, string string [, int limit])
+ * Description: Split string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test bad regular expressions
+ */
+
+echo "*** Testing split() : error conditions ***\n";
+
+$regs = 'original';
+
+var_dump(split("", "hello"));
+var_dump(split("c(d", "hello"));
+var_dump(split("a[b", "hello"));
+var_dump(split("c(d", "hello"));
+var_dump(split("*", "hello"));
+var_dump(split("+", "hello"));
+var_dump(split("?", "hello"));
+var_dump(split("(+?*)", "hello", $regs));
+var_dump(split("h{256}", "hello"));
+var_dump(split("h|", "hello"));
+var_dump(split("h{0}", "hello"));
+var_dump(split("h{2,1}", "hello"));
+var_dump(split('[a-c-e]', 'd'));
+var_dump(split('\\', 'x'));
+var_dump(split('([9-0])', '1', $regs));
+
+//ensure $regs unchanged
+var_dump($regs);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing split() : error conditions ***
+
+Warning: split(): REG_EMPTY in %s on line 16
+bool(false)
+
+Warning: split(): REG_EPAREN in %s on line 17
+bool(false)
+
+Warning: split(): REG_EBRACK in %s on line 18
+bool(false)
+
+Warning: split(): REG_EPAREN in %s on line 19
+bool(false)
+
+Warning: split(): REG_BADRPT in %s on line 20
+bool(false)
+
+Warning: split(): REG_BADRPT in %s on line 21
+bool(false)
+
+Warning: split(): REG_BADRPT in %s on line 22
+bool(false)
+
+Warning: split(): REG_BADRPT in %s on line 23
+bool(false)
+
+Warning: split(): REG_BADBR in %s on line 24
+bool(false)
+
+Warning: split(): REG_EMPTY in %s on line 25
+bool(false)
+
+Warning: split(): REG_EMPTY in %s on line 26
+bool(false)
+
+Warning: split(): REG_BADBR in %s on line 27
+bool(false)
+
+Warning: split(): REG_ERANGE in %s on line 28
+bool(false)
+
+Warning: split(): REG_EESCAPE in %s on line 29
+bool(false)
+
+Warning: split(): REG_ERANGE in %s on line 30
+bool(false)
+string(8) "original"
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/split_variation_001.phpt b/ext/ereg/tests/split_variation_001.phpt
new file mode 100644
index 0000000000..625bf06253
--- /dev/null
+++ b/ext/ereg/tests/split_variation_001.phpt
@@ -0,0 +1,256 @@
+--TEST--
+Test split() function : usage variations - unexpected type for arg 1
+--FILE--
+<?php
+/* Prototype : proto array split(string pattern, string string [, int limit])
+ * Description: Split string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing split() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$string = '1 a 1 Array 1 c ';
+$limit = 5;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for pattern
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( split($value, $string, $limit) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing split() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(64)
+Error: 8 - Undefined variable: unset_var, %s(67)
+
+Arg value 0
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value 1
+array(4) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(3) " a "
+ [2]=>
+ string(7) " Array "
+ [3]=>
+ string(3) " c "
+}
+
+Arg value 12345
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value -2345
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value 10.5
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value -10.5
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value 101234567000
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value 1.07654321E-9
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value 0.5
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(2) {
+ [0]=>
+ string(6) "1 a 1 "
+ [1]=>
+ string(5) " 1 c "
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(2) {
+ [0]=>
+ string(6) "1 a 1 "
+ [1]=>
+ string(5) " 1 c "
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(2) {
+ [0]=>
+ string(6) "1 a 1 "
+ [1]=>
+ string(5) " 1 c "
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(2) {
+ [0]=>
+ string(6) "1 a 1 "
+ [1]=>
+ string(5) " 1 c "
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(2) {
+ [0]=>
+ string(6) "1 a 1 "
+ [1]=>
+ string(5) " 1 c "
+}
+
+Arg value
+Error: 2 - split(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value
+Error: 2 - split(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value 1
+array(4) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(3) " a "
+ [2]=>
+ string(7) " Array "
+ [3]=>
+ string(3) " c "
+}
+
+Arg value
+Error: 2 - split(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value 1
+array(4) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(3) " a "
+ [2]=>
+ string(7) " Array "
+ [3]=>
+ string(3) " c "
+}
+
+Arg value
+Error: 2 - split(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value
+Error: 2 - split(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value
+Error: 2 - split(): REG_EMPTY, %s(74)
+bool(false)
+Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
+
+Arg value
+Error: 4096 - Object of class stdClass could not be converted to string, %s(74)
+Error: 8 - Object of class stdClass to string conversion, %s(74)
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value
+Error: 2 - split(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value
+Error: 2 - split(): REG_EMPTY, %s(74)
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/split_variation_002.phpt b/ext/ereg/tests/split_variation_002.phpt
new file mode 100644
index 0000000000..d7fa8445b3
--- /dev/null
+++ b/ext/ereg/tests/split_variation_002.phpt
@@ -0,0 +1,268 @@
+--TEST--
+Test split() function : usage variations - unexpected type for arg 2
+--FILE--
+<?php
+/* Prototype : proto array split(string pattern, string string [, int limit])
+ * Description: Split string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing split() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$pattern = 'r|j|E';
+$limit = 5;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for string
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( split($pattern, $value, $limit) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing split() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(64)
+Error: 8 - Undefined variable: unset_var, %s(67)
+
+Arg value 0
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+
+Arg value 1
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+
+Arg value 12345
+array(1) {
+ [0]=>
+ string(5) "12345"
+}
+
+Arg value -2345
+array(1) {
+ [0]=>
+ string(5) "-2345"
+}
+
+Arg value 10.5
+array(1) {
+ [0]=>
+ string(4) "10.5"
+}
+
+Arg value -10.5
+array(1) {
+ [0]=>
+ string(5) "-10.5"
+}
+
+Arg value 101234567000
+array(1) {
+ [0]=>
+ string(12) "101234567000"
+}
+
+Arg value 1.07654321E-9
+array(2) {
+ [0]=>
+ string(10) "1.07654321"
+ [1]=>
+ string(2) "-9"
+}
+
+Arg value 0.5
+array(1) {
+ [0]=>
+ string(3) "0.5"
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(3) {
+ [0]=>
+ string(1) "A"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(2) "ay"
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(3) {
+ [0]=>
+ string(1) "A"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(2) "ay"
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(3) {
+ [0]=>
+ string(1) "A"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(2) "ay"
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(3) {
+ [0]=>
+ string(1) "A"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(2) "ay"
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(3) {
+ [0]=>
+ string(1) "A"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(2) "ay"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(0) ""
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(0) ""
+}
+
+Arg value 1
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(0) ""
+}
+
+Arg value 1
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(0) ""
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(0) ""
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(0) ""
+}
+Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
+
+Arg value
+Error: 4096 - Object of class stdClass could not be converted to string, %s(74)
+Error: 8 - Object of class stdClass to string conversion, %s(74)
+array(2) {
+ [0]=>
+ string(2) "Ob"
+ [1]=>
+ string(3) "ect"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(0) ""
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(0) ""
+}
+Done
diff --git a/ext/ereg/tests/split_variation_003.phpt b/ext/ereg/tests/split_variation_003.phpt
new file mode 100644
index 0000000000..ce7c778fe3
--- /dev/null
+++ b/ext/ereg/tests/split_variation_003.phpt
@@ -0,0 +1,239 @@
+--TEST--
+Test split() function : usage variations - unexpected type for arg 3
+--FILE--
+<?php
+/* Prototype : proto array split(string pattern, string string [, int limit])
+ * Description: Split string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+echo "*** Testing split() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$pattern = '[[:space:]]';
+$string = '1 2 3 4 5';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for limit
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( split($pattern, $string, $value) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing split() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(61)
+Error: 8 - Undefined variable: unset_var, %s(64)
+
+Arg value 10.5
+array(5) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "2"
+ [2]=>
+ string(1) "3"
+ [3]=>
+ string(1) "4"
+ [4]=>
+ string(1) "5"
+}
+
+Arg value -10.5
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value 101234567000
+array(5) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "2"
+ [2]=>
+ string(1) "3"
+ [3]=>
+ string(1) "4"
+ [4]=>
+ string(1) "5"
+}
+
+Arg value 1.07654321E-9
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value 0.5
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value Array
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value Array
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value Array
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value Array
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value Array
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value 1
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value 1
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value string
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value string
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+Error: 4096 - Object of class stdClass could not be converted to string, %s(70)
+
+Arg value
+Error: 8 - Object of class stdClass could not be converted to int, %s(71)
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/split_variation_004.phpt b/ext/ereg/tests/split_variation_004.phpt
new file mode 100644
index 0000000000..fbd76277ae
--- /dev/null
+++ b/ext/ereg/tests/split_variation_004.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test split() function : usage variations - out-of-range values for limit
+--FILE--
+<?php
+/* Prototype : proto array split(string pattern, string string [, int limit])
+ * Description: Split string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+echo "*** Testing split() : usage variations ***\n";
+
+$pattern = '[[:space:]]';
+$string = '1 2 3 4 5';
+var_dump(split($pattern, $string, 0));
+var_dump(split($pattern, $string, -10));
+var_dump(split($pattern, $string, 10E20));
+
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing split() : usage variations ***
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+array(5) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "2"
+ [2]=>
+ string(1) "3"
+ [3]=>
+ string(1) "4"
+ [4]=>
+ string(1) "5"
+}
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/spliti_basic_001.phpt b/ext/ereg/tests/spliti_basic_001.phpt
new file mode 100644
index 0000000000..c178aef49d
--- /dev/null
+++ b/ext/ereg/tests/spliti_basic_001.phpt
@@ -0,0 +1,129 @@
+--TEST--
+Test spliti() function : basic functionality - test a number of simple spliti, specifying a limit
+--FILE--
+<?php
+/* Prototype : proto array spliti(string pattern, string string [, int limit])
+ * Description: spliti string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test a number of simple spliti, specifying a limit
+ */
+
+echo "*** Testing ereg() : basic functionality ***\n";
+
+include(dirname(__FILE__) . '/regular_expressions.inc');
+
+foreach ($expressions as $re) {
+ list($pattern,$string) = $re;
+ echo "\n--> Pattern: '$pattern'; match: '$string'\n";
+ var_dump(spliti($pattern, $string . ' |1| ' . $string . ' |2| ' . $string, 2));
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg() : basic functionality ***
+
+--> Pattern: '..(a|b|c)(a|b|c)..'; match: '--- ab ---'
+array(2) {
+ [0]=>
+ string(2) "--"
+ [1]=>
+ string(32) "-- |1| --- ab --- |2| --- ab ---"
+}
+
+--> Pattern: '()'; match: ''
+
+Warning: spliti(): Invalid Regular Expression to spliti() in %s on line 19
+bool(false)
+
+--> Pattern: '()'; match: 'abcdef'
+
+Warning: spliti(): Invalid Regular Expression to spliti() in %s on line 19
+bool(false)
+
+--> Pattern: '[x]|[^x]'; match: 'abcdef'
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(27) "bcdef |1| abcdef |2| abcdef"
+}
+
+--> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; match: '--- aaa bbb ccc ddd ---'
+array(2) {
+ [0]=>
+ string(4) "--- "
+ [1]=>
+ string(60) " --- |1| --- aaa bbb ccc ddd --- |2| --- aaa bbb ccc ddd ---"
+}
+
+--> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; match: '\`^.[$()|*+?{''
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(38) " |1| \`^.[$()|*+?{' |2| \`^.[$()|*+?{'"
+}
+
+--> Pattern: '\a'; match: 'a'
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(12) " |1| a |2| a"
+}
+
+--> Pattern: '[0-9][^0-9]'; match: '2a'
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(14) " |1| 2a |2| 2a"
+}
+
+--> Pattern: '^[[:alnum:]]{62,62}$'; match: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+array(1) {
+ [0]=>
+ string(196) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |1| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |2| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+}
+
+--> Pattern: '^[[:digit:]]{5}'; match: '0123456789'
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(35) "56789 |1| 0123456789 |2| 0123456789"
+}
+
+--> Pattern: '[[:digit:]]{5}$'; match: '0123456789'
+array(2) {
+ [0]=>
+ string(35) "0123456789 |1| 0123456789 |2| 01234"
+ [1]=>
+ string(0) ""
+}
+
+--> Pattern: '[[:blank:]]{1,10}'; match: '
+ '
+array(2) {
+ [0]=>
+ string(1) "
+"
+ [1]=>
+ string(15) "|1|
+ |2|
+ "
+}
+
+--> Pattern: '[[:print:]]{3}'; match: ' a '
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(16) " |1| a |2| a "
+}
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/spliti_basic_002.phpt b/ext/ereg/tests/spliti_basic_002.phpt
new file mode 100644
index 0000000000..606cbadd7a
--- /dev/null
+++ b/ext/ereg/tests/spliti_basic_002.phpt
@@ -0,0 +1,227 @@
+--TEST--
+Test spliti() function : basic functionality - test a number of simple spliti, without specifying a limit
+--FILE--
+<?php
+/* Prototype : proto array spliti(string pattern, string string [, int limit])
+ * Description: spliti string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test a number of simple spliti, without specifying a limit
+ */
+
+echo "*** Testing ereg() : basic functionality ***\n";
+
+include(dirname(__FILE__) . '/regular_expressions.inc');
+
+foreach ($expressions as $re) {
+ list($pattern,$string) = $re;
+ echo "\n--> Pattern: '$pattern'; match: '$string'\n";
+ var_dump(spliti($pattern, $string . ' |1| ' . $string . ' |2| ' . $string));
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing ereg() : basic functionality ***
+
+--> Pattern: '..(a|b|c)(a|b|c)..'; match: '--- ab ---'
+array(4) {
+ [0]=>
+ string(2) "--"
+ [1]=>
+ string(9) "-- |1| --"
+ [2]=>
+ string(9) "-- |2| --"
+ [3]=>
+ string(2) "--"
+}
+
+--> Pattern: '()'; match: ''
+
+Warning: spliti(): Invalid Regular Expression to spliti() in %s on line 19
+bool(false)
+
+--> Pattern: '()'; match: 'abcdef'
+
+Warning: spliti(): Invalid Regular Expression to spliti() in %s on line 19
+bool(false)
+
+--> Pattern: '[x]|[^x]'; match: 'abcdef'
+array(29) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(0) ""
+ [8]=>
+ string(0) ""
+ [9]=>
+ string(0) ""
+ [10]=>
+ string(0) ""
+ [11]=>
+ string(0) ""
+ [12]=>
+ string(0) ""
+ [13]=>
+ string(0) ""
+ [14]=>
+ string(0) ""
+ [15]=>
+ string(0) ""
+ [16]=>
+ string(0) ""
+ [17]=>
+ string(0) ""
+ [18]=>
+ string(0) ""
+ [19]=>
+ string(0) ""
+ [20]=>
+ string(0) ""
+ [21]=>
+ string(0) ""
+ [22]=>
+ string(0) ""
+ [23]=>
+ string(0) ""
+ [24]=>
+ string(0) ""
+ [25]=>
+ string(0) ""
+ [26]=>
+ string(0) ""
+ [27]=>
+ string(0) ""
+ [28]=>
+ string(0) ""
+}
+
+--> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; match: '--- aaa bbb ccc ddd ---'
+array(4) {
+ [0]=>
+ string(4) "--- "
+ [1]=>
+ string(13) " --- |1| --- "
+ [2]=>
+ string(13) " --- |2| --- "
+ [3]=>
+ string(4) " ---"
+}
+
+--> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; match: '\`^.[$()|*+?{''
+array(4) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) " |1| "
+ [2]=>
+ string(5) " |2| "
+ [3]=>
+ string(0) ""
+}
+
+--> Pattern: '\a'; match: 'a'
+array(4) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) " |1| "
+ [2]=>
+ string(5) " |2| "
+ [3]=>
+ string(0) ""
+}
+
+--> Pattern: '[0-9][^0-9]'; match: '2a'
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(2) " |"
+ [2]=>
+ string(1) " "
+ [3]=>
+ string(2) " |"
+ [4]=>
+ string(1) " "
+ [5]=>
+ string(0) ""
+}
+
+--> Pattern: '^[[:alnum:]]{62,62}$'; match: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+array(1) {
+ [0]=>
+ string(196) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |1| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |2| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+}
+
+--> Pattern: '^[[:digit:]]{5}'; match: '0123456789'
+array(3) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(30) " |1| 0123456789 |2| 0123456789"
+}
+
+--> Pattern: '[[:digit:]]{5}$'; match: '0123456789'
+array(2) {
+ [0]=>
+ string(35) "0123456789 |1| 0123456789 |2| 01234"
+ [1]=>
+ string(0) ""
+}
+
+--> Pattern: '[[:blank:]]{1,10}'; match: '
+ '
+array(6) {
+ [0]=>
+ string(1) "
+"
+ [1]=>
+ string(3) "|1|"
+ [2]=>
+ string(1) "
+"
+ [3]=>
+ string(3) "|2|"
+ [4]=>
+ string(1) "
+"
+ [5]=>
+ string(0) ""
+}
+
+--> Pattern: '[[:print:]]{3}'; match: ' a '
+array(7) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(1) " "
+}
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/spliti_basic_003.phpt b/ext/ereg/tests/spliti_basic_003.phpt
new file mode 100644
index 0000000000..143f1a1961
--- /dev/null
+++ b/ext/ereg/tests/spliti_basic_003.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Test spliti() function : basic functionality - a few non-matches
+--FILE--
+<?php
+/* Prototype : proto array spliti(string pattern, string string [, int limit])
+ * Description: spliti string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+$replacement = 'r';
+
+var_dump(spliti('[A-Z]', '-- 0 --'));
+var_dump(spliti('(a){4}', '--- aaa ---'));
+var_dump(spliti('^a', '--- ba ---'));
+var_dump(spliti('b$', '--- ba ---'));
+var_dump(spliti('[:alpha:]', '--- x ---'));
+
+
+echo "Done";
+?>
+--EXPECTF--
+array(1) {
+ [0]=>
+ string(7) "-- 0 --"
+}
+array(1) {
+ [0]=>
+ string(11) "--- aaa ---"
+}
+array(1) {
+ [0]=>
+ string(10) "--- ba ---"
+}
+array(1) {
+ [0]=>
+ string(10) "--- ba ---"
+}
+array(1) {
+ [0]=>
+ string(9) "--- x ---"
+}
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/spliti_basic_004.phpt b/ext/ereg/tests/spliti_basic_004.phpt
new file mode 100644
index 0000000000..95edc158d9
--- /dev/null
+++ b/ext/ereg/tests/spliti_basic_004.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Test spliti() function : basic functionality - confirm case insensitivity
+--FILE--
+<?php
+/* Prototype : proto array spliti(string pattern, string string [, int limit])
+ * Description: spliti string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+$replacement = 'r';
+
+var_dump(spliti('[a-z]', '--- A ---'));
+var_dump(spliti('[A-Z]', '--- a ---'));
+var_dump(spliti('[[:lower:]]', '--- A ---'));
+var_dump(spliti('[[:upper:]]', '--- a ---'));
+
+echo "Done";
+?>
+--EXPECTF--
+array(2) {
+ [0]=>
+ string(4) "--- "
+ [1]=>
+ string(4) " ---"
+}
+array(2) {
+ [0]=>
+ string(4) "--- "
+ [1]=>
+ string(4) " ---"
+}
+array(2) {
+ [0]=>
+ string(4) "--- "
+ [1]=>
+ string(4) " ---"
+}
+array(2) {
+ [0]=>
+ string(4) "--- "
+ [1]=>
+ string(4) " ---"
+}
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/spliti_error_001.phpt b/ext/ereg/tests/spliti_error_001.phpt
new file mode 100644
index 0000000000..44d2be6185
--- /dev/null
+++ b/ext/ereg/tests/spliti_error_001.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Test spliti() function : error conditions - wrong number of args
+--FILE--
+<?php
+/* Prototype : proto array spliti(string pattern, string string [, int limit])
+ * Description: spliti string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+echo "*** Testing spliti() : error conditions - wrong number of args ***\n";
+
+
+//Test spliti with one more than the expected number of arguments
+echo "\n-- Testing spliti() function with more than expected no. of arguments --\n";
+$pattern = 'string_val';
+$string = 'string_val';
+$limit = 10;
+$extra_arg = 10;
+var_dump( spliti($pattern, $string, $limit, $extra_arg) );
+
+// Testing spliti with one less than the expected number of arguments
+echo "\n-- Testing spliti() function with less than expected no. of arguments --\n";
+$pattern = 'string_val';
+var_dump( spliti($pattern) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing spliti() : error conditions - wrong number of args ***
+
+-- Testing spliti() function with more than expected no. of arguments --
+
+Warning: Wrong parameter count for spliti() in %s on line 17
+NULL
+
+-- Testing spliti() function with less than expected no. of arguments --
+
+Warning: Wrong parameter count for spliti() in %s on line 22
+NULL
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/spliti_error_002.phpt b/ext/ereg/tests/spliti_error_002.phpt
new file mode 100644
index 0000000000..030fb2b243
--- /dev/null
+++ b/ext/ereg/tests/spliti_error_002.phpt
@@ -0,0 +1,88 @@
+--TEST--
+Test spliti() function : error conditions - test bad regular expressions
+--FILE--
+<?php
+/* Prototype : proto array spliti(string pattern, string string [, int limit])
+ * Description: spliti string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+/*
+ * Test bad regular expressions
+ */
+
+echo "*** Testing spliti() : error conditions ***\n";
+
+$regs = 'original';
+
+var_dump(spliti("", "hello"));
+var_dump(spliti("c(d", "hello"));
+var_dump(spliti("a[b", "hello"));
+var_dump(spliti("c(d", "hello"));
+var_dump(spliti("*", "hello"));
+var_dump(spliti("+", "hello"));
+var_dump(spliti("?", "hello"));
+var_dump(spliti("(+?*)", "hello", $regs));
+var_dump(spliti("h{256}", "hello"));
+var_dump(spliti("h|", "hello"));
+var_dump(spliti("h{0}", "hello"));
+var_dump(spliti("h{2,1}", "hello"));
+var_dump(spliti('[a-c-e]', 'd'));
+var_dump(spliti('\\', 'x'));
+var_dump(spliti('([9-0])', '1', $regs));
+
+//ensure $regs unchanged
+var_dump($regs);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing spliti() : error conditions ***
+
+Warning: spliti(): REG_EMPTY in %s on line 16
+bool(false)
+
+Warning: spliti(): REG_EPAREN in %s on line 17
+bool(false)
+
+Warning: spliti(): REG_EBRACK in %s on line 18
+bool(false)
+
+Warning: spliti(): REG_EPAREN in %s on line 19
+bool(false)
+
+Warning: spliti(): REG_BADRPT in %s on line 20
+bool(false)
+
+Warning: spliti(): REG_BADRPT in %s on line 21
+bool(false)
+
+Warning: spliti(): REG_BADRPT in %s on line 22
+bool(false)
+
+Warning: spliti(): REG_BADRPT in %s on line 23
+bool(false)
+
+Warning: spliti(): REG_BADBR in %s on line 24
+bool(false)
+
+Warning: spliti(): REG_EMPTY in %s on line 25
+bool(false)
+
+Warning: spliti(): REG_EMPTY in %s on line 26
+bool(false)
+
+Warning: spliti(): REG_BADBR in %s on line 27
+bool(false)
+
+Warning: spliti(): REG_ERANGE in %s on line 28
+bool(false)
+
+Warning: spliti(): REG_EESCAPE in %s on line 29
+bool(false)
+
+Warning: spliti(): REG_ERANGE in %s on line 30
+bool(false)
+string(8) "original"
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/spliti_variation_001.phpt b/ext/ereg/tests/spliti_variation_001.phpt
new file mode 100644
index 0000000000..b9b15b5895
--- /dev/null
+++ b/ext/ereg/tests/spliti_variation_001.phpt
@@ -0,0 +1,256 @@
+--TEST--
+Test spliti() function : usage variations - unexpected type for arg 1
+--FILE--
+<?php
+/* Prototype : proto array spliti(string pattern, string string [, int limit])
+ * Description: spliti string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing spliti() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$string = '1 a 1 Array 1 c ';
+$limit = 5;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for pattern
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( spliti($value, $string, $limit) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing spliti() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(64)
+Error: 8 - Undefined variable: unset_var, %s(67)
+
+Arg value 0
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value 1
+array(4) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(3) " a "
+ [2]=>
+ string(7) " Array "
+ [3]=>
+ string(3) " c "
+}
+
+Arg value 12345
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value -2345
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value 10.5
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value -10.5
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value 101234567000
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value 1.07654321E-9
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value 0.5
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(2) {
+ [0]=>
+ string(6) "1 a 1 "
+ [1]=>
+ string(5) " 1 c "
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(2) {
+ [0]=>
+ string(6) "1 a 1 "
+ [1]=>
+ string(5) " 1 c "
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(2) {
+ [0]=>
+ string(6) "1 a 1 "
+ [1]=>
+ string(5) " 1 c "
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(2) {
+ [0]=>
+ string(6) "1 a 1 "
+ [1]=>
+ string(5) " 1 c "
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(2) {
+ [0]=>
+ string(6) "1 a 1 "
+ [1]=>
+ string(5) " 1 c "
+}
+
+Arg value
+Error: 2 - spliti(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value
+Error: 2 - spliti(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value 1
+array(4) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(3) " a "
+ [2]=>
+ string(7) " Array "
+ [3]=>
+ string(3) " c "
+}
+
+Arg value
+Error: 2 - spliti(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value 1
+array(4) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(3) " a "
+ [2]=>
+ string(7) " Array "
+ [3]=>
+ string(3) " c "
+}
+
+Arg value
+Error: 2 - spliti(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value
+Error: 2 - spliti(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value
+Error: 2 - spliti(): REG_EMPTY, %s(74)
+bool(false)
+Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
+
+Arg value
+Error: 4096 - Object of class stdClass could not be converted to string, %s(74)
+Error: 8 - Object of class stdClass to string conversion, %s(74)
+array(1) {
+ [0]=>
+ string(16) "1 a 1 Array 1 c "
+}
+
+Arg value
+Error: 2 - spliti(): REG_EMPTY, %s(74)
+bool(false)
+
+Arg value
+Error: 2 - spliti(): REG_EMPTY, %s(74)
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/spliti_variation_002.phpt b/ext/ereg/tests/spliti_variation_002.phpt
new file mode 100644
index 0000000000..a1e51bdb61
--- /dev/null
+++ b/ext/ereg/tests/spliti_variation_002.phpt
@@ -0,0 +1,270 @@
+--TEST--
+Test spliti() function : usage variations - unexpected type for arg 2
+--FILE--
+<?php
+/* Prototype : proto array spliti(string pattern, string string [, int limit])
+ * Description: spliti string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing spliti() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$pattern = 'r|j|E';
+$limit = 5;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for string
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( spliti($pattern, $value, $limit) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing spliti() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(64)
+Error: 8 - Undefined variable: unset_var, %s(67)
+
+Arg value 0
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+
+Arg value 1
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+
+Arg value 12345
+array(1) {
+ [0]=>
+ string(5) "12345"
+}
+
+Arg value -2345
+array(1) {
+ [0]=>
+ string(5) "-2345"
+}
+
+Arg value 10.5
+array(1) {
+ [0]=>
+ string(4) "10.5"
+}
+
+Arg value -10.5
+array(1) {
+ [0]=>
+ string(5) "-10.5"
+}
+
+Arg value 101234567000
+array(1) {
+ [0]=>
+ string(12) "101234567000"
+}
+
+Arg value 1.07654321E-9
+array(2) {
+ [0]=>
+ string(10) "1.07654321"
+ [1]=>
+ string(2) "-9"
+}
+
+Arg value 0.5
+array(1) {
+ [0]=>
+ string(3) "0.5"
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(3) {
+ [0]=>
+ string(1) "A"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(2) "ay"
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(3) {
+ [0]=>
+ string(1) "A"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(2) "ay"
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(3) {
+ [0]=>
+ string(1) "A"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(2) "ay"
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(3) {
+ [0]=>
+ string(1) "A"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(2) "ay"
+}
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(74)
+array(3) {
+ [0]=>
+ string(1) "A"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(2) "ay"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(0) ""
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(0) ""
+}
+
+Arg value 1
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(0) ""
+}
+
+Arg value 1
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(0) ""
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(0) ""
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(0) ""
+}
+Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
+
+Arg value
+Error: 4096 - Object of class stdClass could not be converted to string, %s(74)
+Error: 8 - Object of class stdClass to string conversion, %s(74)
+array(3) {
+ [0]=>
+ string(2) "Ob"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(2) "ct"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(0) ""
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(0) ""
+}
+Done
diff --git a/ext/ereg/tests/spliti_variation_003.phpt b/ext/ereg/tests/spliti_variation_003.phpt
new file mode 100644
index 0000000000..7e3d80f885
--- /dev/null
+++ b/ext/ereg/tests/spliti_variation_003.phpt
@@ -0,0 +1,239 @@
+--TEST--
+Test spliti() function : usage variations - unexpected type for arg 3
+--FILE--
+<?php
+/* Prototype : proto array spliti(string pattern, string string [, int limit])
+ * Description: spliti string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+echo "*** Testing spliti() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$pattern = '[[:space:]]';
+$string = '1 2 3 4 5';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for limit
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( spliti($pattern, $string, $value) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing spliti() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(61)
+Error: 8 - Undefined variable: unset_var, %s(64)
+
+Arg value 10.5
+array(5) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "2"
+ [2]=>
+ string(1) "3"
+ [3]=>
+ string(1) "4"
+ [4]=>
+ string(1) "5"
+}
+
+Arg value -10.5
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value 101234567000
+array(5) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "2"
+ [2]=>
+ string(1) "3"
+ [3]=>
+ string(1) "4"
+ [4]=>
+ string(1) "5"
+}
+
+Arg value 1.07654321E-9
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value 0.5
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value Array
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value Array
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value Array
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value Array
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value Array
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value 1
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value 1
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value string
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value string
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+Error: 4096 - Object of class stdClass could not be converted to string, %s(70)
+
+Arg value
+Error: 8 - Object of class stdClass could not be converted to int, %s(71)
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+
+Arg value
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/spliti_variation_004.phpt b/ext/ereg/tests/spliti_variation_004.phpt
new file mode 100644
index 0000000000..7a331be367
--- /dev/null
+++ b/ext/ereg/tests/spliti_variation_004.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test spliti() function : usage variations - out-of-range values for limit
+--FILE--
+<?php
+/* Prototype : proto array spliti(string pattern, string string [, int limit])
+ * Description: spliti string into array by regular expression
+ * Source code: ext/standard/reg.c
+ * Alias to functions:
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+echo "*** Testing spliti() : usage variations ***\n";
+
+$pattern = '[[:space:]]';
+$string = '1 2 3 4 5';
+var_dump(spliti($pattern, $string, 0));
+var_dump(spliti($pattern, $string, -10));
+var_dump(spliti($pattern, $string, 10E20));
+
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing spliti() : usage variations ***
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+array(1) {
+ [0]=>
+ string(9) "1 2 3 4 5"
+}
+array(5) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "2"
+ [2]=>
+ string(1) "3"
+ [3]=>
+ string(1) "4"
+ [4]=>
+ string(1) "5"
+}
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/sql_regcase_basic_001.phpt b/ext/ereg/tests/sql_regcase_basic_001.phpt
new file mode 100644
index 0000000000..7657fa28c7
--- /dev/null
+++ b/ext/ereg/tests/sql_regcase_basic_001.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Test sql_regcase() function : basic functionality
+--FILE--
+<?php
+/* Prototype : proto string sql_regcase(string string)
+ * Description: Make regular expression for case insensitive match
+ * Source code: ext/standard/reg.c
+ * Alias to functions: msql_regcase
+ */
+
+echo "*** Testing sql_regcase() : basic functionality ***\n";
+
+
+// Initialise all required variables
+$string = 'string_Val-0';
+
+// Calling sql_regcase() with all possible arguments
+var_dump( sql_regcase($string) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing sql_regcase() : basic functionality ***
+string(39) "[Ss][Tt][Rr][Ii][Nn][Gg]_[Vv][Aa][Ll]-0"
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/sql_regcase_error_001.phpt b/ext/ereg/tests/sql_regcase_error_001.phpt
new file mode 100644
index 0000000000..3ab9fd8db8
--- /dev/null
+++ b/ext/ereg/tests/sql_regcase_error_001.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test sql_regcase() function : error conditions
+--FILE--
+<?php
+/* Prototype : proto string sql_regcase(string string)
+ * Description: Make regular expression for case insensitive match
+ * Source code: ext/standard/reg.c
+ * Alias to functions: msql_regcase
+ */
+
+echo "*** Testing sql_regcase() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing sql_regcase() function with Zero arguments --\n";
+var_dump( sql_regcase() );
+
+//Test sql_regcase with one more than the expected number of arguments
+echo "\n-- Testing sql_regcase() function with more than expected no. of arguments --\n";
+$string = 'string_val';
+$extra_arg = 10;
+var_dump( sql_regcase($string, $extra_arg) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing sql_regcase() : error conditions ***
+
+-- Testing sql_regcase() function with Zero arguments --
+
+Warning: Wrong parameter count for sql_regcase() in %s on line 12
+NULL
+
+-- Testing sql_regcase() function with more than expected no. of arguments --
+
+Warning: Wrong parameter count for sql_regcase() in %s on line 18
+NULL
+Done \ No newline at end of file
diff --git a/ext/ereg/tests/sql_regcase_variation_001.phpt b/ext/ereg/tests/sql_regcase_variation_001.phpt
new file mode 100644
index 0000000000..ed0bef06da
--- /dev/null
+++ b/ext/ereg/tests/sql_regcase_variation_001.phpt
@@ -0,0 +1,167 @@
+--TEST--
+Test sql_regcase() function : usage variations - unexpected arg type
+--FILE--
+<?php
+/* Prototype : proto string sql_regcase(string string)
+ * Description: Make regular expression for case insensitive match
+ * Source code: ext/standard/reg.c
+ * Alias to functions: msql_regcase
+ */
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+}
+set_error_handler('test_error_handler');
+
+echo "*** Testing sql_regcase() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new stdclass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for string
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( sql_regcase($value) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing sql_regcase() : usage variations ***
+Error: 8 - Undefined variable: undefined_var, %s(62)
+Error: 8 - Undefined variable: unset_var, %s(65)
+
+Arg value 0
+string(1) "0"
+
+Arg value 1
+string(1) "1"
+
+Arg value 12345
+string(5) "12345"
+
+Arg value -2345
+string(5) "-2345"
+
+Arg value 10.5
+string(4) "10.5"
+
+Arg value -10.5
+string(5) "-10.5"
+
+Arg value 101234567000
+string(12) "101234567000"
+
+Arg value 1.07654321E-9
+string(16) "1.07654321[Ee]-9"
+
+Arg value 0.5
+string(3) "0.5"
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(72)
+string(20) "[Aa][Rr][Rr][Aa][Yy]"
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(72)
+string(20) "[Aa][Rr][Rr][Aa][Yy]"
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(72)
+string(20) "[Aa][Rr][Rr][Aa][Yy]"
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(72)
+string(20) "[Aa][Rr][Rr][Aa][Yy]"
+
+Arg value Array
+Error: 8 - Array to string conversion, %s(72)
+string(20) "[Aa][Rr][Rr][Aa][Yy]"
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+
+Arg value 1
+string(1) "1"
+
+Arg value
+string(0) ""
+
+Arg value 1
+string(1) "1"
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+Error: 4096 - Object of class stdClass could not be converted to string, %s(71)
+
+Arg value
+Error: 4096 - Object of class stdClass could not be converted to string, %s(72)
+Error: 8 - Object of class stdClass to string conversion, %s(72)
+string(24) "[Oo][Bb][Jj][Ee][Cc][Tt]"
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+Done \ No newline at end of file