Adding some tests for ereg and url functions.

This commit is contained in:
Robin Fernandes 2008-04-11 08:57:17 +00:00
parent 7b22726093
commit bcd9a07d6c
90 changed files with 11026 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 "),
);
?>

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,24 @@
--TEST--
Test base64_decode() function : basic functionality - ensure all base64 alphabet is supported.
--FILE--
<?php
/* Prototype : proto string base64_decode(string str[, bool strict])
* Description: Decodes string using MIME base64 algorithm
* Source code: ext/standard/base64.c
* Alias to functions:
*/
echo "Decode an input string containing the whole base64 alphabet:\n";
$allbase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var_dump(bin2hex(base64_decode($allbase64)));
var_dump(bin2hex(base64_decode($allbase64, false)));
var_dump(bin2hex(base64_decode($allbase64, true)));
echo "Done";
?>
--EXPECTF--
Decode an input string containing the whole base64 alphabet:
string(96) "00108310518720928b30d38f41149351559761969b71d79f8218a39259a7a29aabb2dbafc31cb3d35db7e39ebbf3dfbf"
string(96) "00108310518720928b30d38f41149351559761969b71d79f8218a39259a7a29aabb2dbafc31cb3d35db7e39ebbf3dfbf"
string(96) "00108310518720928b30d38f41149351559761969b71d79f8218a39259a7a29aabb2dbafc31cb3d35db7e39ebbf3dfbf"
Done

View file

@ -0,0 +1,47 @@
--TEST--
Test base64_decode() function : basic functionality - strict vs non-strict with non-base64 chars.
--FILE--
<?php
/* Prototype : proto string base64_decode(string str[, bool strict])
* Description: Decodes string using MIME base64 algorithm
* Source code: ext/standard/base64.c
* Alias to functions:
*/
echo "Decode 'hello world!':\n";
$noWhiteSpace = "aGVsbG8gd29ybGQh";
var_dump(base64_decode($noWhiteSpace));
var_dump(base64_decode($noWhiteSpace, false));
var_dump(base64_decode($noWhiteSpace, true));
echo "\nWhitespace does not affect base64_decode, even with \$strict===true:\n";
$withWhiteSpace = "a GVs bG8gd2
9ybGQh";
var_dump(base64_decode($withWhiteSpace));
var_dump(base64_decode($withWhiteSpace, false));
var_dump(base64_decode($withWhiteSpace, true));
echo "\nOther chars outside the base64 alphabet are ignored when \$strict===false, but cause failure with \$strict===true:\n";
$badChars = $noWhiteSpace . '*';
var_dump(base64_decode($badChars));
var_dump(base64_decode($badChars, false));
var_dump(base64_decode($badChars, true));
echo "Done";
?>
--EXPECTF--
Decode 'hello world!':
string(12) "hello world!"
string(12) "hello world!"
string(12) "hello world!"
Whitespace does not affect base64_decode, even with $strict===true:
string(12) "hello world!"
string(12) "hello world!"
string(12) "hello world!"
Other chars outside the base64 alphabet are ignored when $strict===false, but cause failure with $strict===true:
string(12) "hello world!"
string(12) "hello world!"
bool(false)
Done

View file

@ -0,0 +1,38 @@
--TEST--
Test base64_decode() function : error conditions - wrong number of args
--FILE--
<?php
/* Prototype : proto string base64_decode(string str[, bool strict])
* Description: Decodes string using MIME base64 algorithm
* Source code: ext/standard/base64.c
* Alias to functions:
*/
echo "*** Testing base64_decode() : error conditions ***\n";
// Zero arguments
echo "\n-- Testing base64_decode() function with Zero arguments --\n";
var_dump( base64_decode() );
//Test base64_decode with one more than the expected number of arguments
echo "\n-- Testing base64_decode() function with more than expected no. of arguments --\n";
$str = 'string_val';
$strict = true;
$extra_arg = 10;
var_dump( base64_decode($str, $strict, $extra_arg) );
echo "Done";
?>
--EXPECTF--
*** Testing base64_decode() : error conditions ***
-- Testing base64_decode() function with Zero arguments --
Warning: base64_decode() expects at least 1 parameter, 0 given in %s on line 12
NULL
-- Testing base64_decode() function with more than expected no. of arguments --
Warning: base64_decode() expects at most 2 parameters, 3 given in %s on line 19
NULL
Done

View file

@ -0,0 +1,167 @@
--TEST--
Test base64_decode() function : usage variations - unexpected types for arg 1
--FILE--
<?php
/* Prototype : proto string base64_decode(string str[, bool strict])
* Description: Decodes string using MIME base64 algorithm
* Source code: ext/standard/base64.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 base64_decode() : usage variations ***\n";
// Initialise function arguments not being substituted (if any)
$strict = true;
//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 str
foreach($values as $value) {
echo "\nArg value $value \n";
var_dump( base64_decode($value, $strict) );
};
echo "Done";
?>
--EXPECTF--
*** Testing base64_decode() : usage variations ***
Error: 8 - Undefined variable: undefined_var, %s(63)
Error: 8 - Undefined variable: unset_var, %s(66)
Arg value 0
string(0) ""
Arg value 1
string(0) ""
Arg value 12345
string(3) "×mø"
Arg value -2345
bool(false)
Arg value 10.5
bool(false)
Arg value -10.5
bool(false)
Arg value 101234567000
string(9) "×MvߎzïM4"
Arg value 1.07654321E-9
bool(false)
Arg value 0.5
bool(false)
Arg value Array
Error: 2 - base64_decode() expects parameter 1 to be string, array given, %s(73)
NULL
Arg value Array
Error: 2 - base64_decode() expects parameter 1 to be string, array given, %s(73)
NULL
Arg value Array
Error: 2 - base64_decode() expects parameter 1 to be string, array given, %s(73)
NULL
Arg value Array
Error: 2 - base64_decode() expects parameter 1 to be string, array given, %s(73)
NULL
Arg value Array
Error: 2 - base64_decode() expects parameter 1 to be string, array given, %s(73)
NULL
Arg value
string(0) ""
Arg value
string(0) ""
Arg value 1
string(0) ""
Arg value
string(0) ""
Arg value 1
string(0) ""
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(72)
Arg value
Error: 2 - base64_decode() expects parameter 1 to be string, object given, %s(73)
NULL
Arg value
string(0) ""
Arg value
string(0) ""
Done

View file

@ -0,0 +1,177 @@
--TEST--
Test base64_decode() function : usage variations - unexpected types for arg 2
--FILE--
<?php
/* Prototype : proto string base64_decode(string str[, bool strict])
* Description: Decodes string using MIME base64 algorithm
* Source code: ext/standard/base64.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 base64_decode() : usage variations ***\n";
// Initialise function arguments not being substituted (if any)
$str = 'aGVsbG8gd29ybGQh!';
//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
"",
'',
// string data
"string",
'string',
// object data
new stdclass(),
// undefined data
$undefined_var,
// unset data
$unset_var,
);
// loop through each element of the array for strict
foreach($values as $value) {
echo "\nArg value $value \n";
var_dump( base64_decode($str, $value) );
};
echo "Done";
?>
--EXPECTF--
*** Testing base64_decode() : usage variations ***
Error: 8 - Undefined variable: undefined_var, %s(67)
Error: 8 - Undefined variable: unset_var, %s(70)
Arg value 0
string(12) "hello world!"
Arg value 1
bool(false)
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: 2 - base64_decode() expects parameter 2 to be boolean, array given, %s(77)
NULL
Arg value Array
Error: 2 - base64_decode() expects parameter 2 to be boolean, array given, %s(77)
NULL
Arg value Array
Error: 2 - base64_decode() expects parameter 2 to be boolean, array given, %s(77)
NULL
Arg value Array
Error: 2 - base64_decode() expects parameter 2 to be boolean, array given, %s(77)
NULL
Arg value Array
Error: 2 - base64_decode() expects parameter 2 to be boolean, array given, %s(77)
NULL
Arg value
string(12) "hello world!"
Arg value
string(12) "hello world!"
Arg value 1
bool(false)
Arg value
string(12) "hello world!"
Arg value 1
bool(false)
Arg value
string(12) "hello world!"
Arg value
string(12) "hello world!"
Arg value
string(12) "hello world!"
Arg value string
bool(false)
Arg value string
bool(false)
Error: 4096 - Object of class stdClass could not be converted to string, %s(76)
Arg value
Error: 2 - base64_decode() expects parameter 2 to be boolean, object given, %s(77)
NULL
Arg value
string(12) "hello world!"
Arg value
string(12) "hello world!"
Done

View file

@ -0,0 +1,283 @@
--TEST--
Test base64_encode() function : basic functionality
--FILE--
<?php
/* Prototype : proto string base64_encode(string str)
* Description: Encodes string using MIME base64 algorithm
* Source code: ext/standard/base64.c
* Alias to functions:
*/
/*
* Test base64_encode with single byte values.
*/
echo "*** Testing base64_encode() : basic functionality ***\n";
for ($i=0; $i<256; $i++) {
$str = pack("c", $i);
$enc = base64_encode($str);
printf("0x%X: %s\n", $i, $enc);
}
echo "Done";
?>
--EXPECTF--
*** Testing base64_encode() : basic functionality ***
0x0: AA==
0x1: AQ==
0x2: Ag==
0x3: Aw==
0x4: BA==
0x5: BQ==
0x6: Bg==
0x7: Bw==
0x8: CA==
0x9: CQ==
0xA: Cg==
0xB: Cw==
0xC: DA==
0xD: DQ==
0xE: Dg==
0xF: Dw==
0x10: EA==
0x11: EQ==
0x12: Eg==
0x13: Ew==
0x14: FA==
0x15: FQ==
0x16: Fg==
0x17: Fw==
0x18: GA==
0x19: GQ==
0x1A: Gg==
0x1B: Gw==
0x1C: HA==
0x1D: HQ==
0x1E: Hg==
0x1F: Hw==
0x20: IA==
0x21: IQ==
0x22: Ig==
0x23: Iw==
0x24: JA==
0x25: JQ==
0x26: Jg==
0x27: Jw==
0x28: KA==
0x29: KQ==
0x2A: Kg==
0x2B: Kw==
0x2C: LA==
0x2D: LQ==
0x2E: Lg==
0x2F: Lw==
0x30: MA==
0x31: MQ==
0x32: Mg==
0x33: Mw==
0x34: NA==
0x35: NQ==
0x36: Ng==
0x37: Nw==
0x38: OA==
0x39: OQ==
0x3A: Og==
0x3B: Ow==
0x3C: PA==
0x3D: PQ==
0x3E: Pg==
0x3F: Pw==
0x40: QA==
0x41: QQ==
0x42: Qg==
0x43: Qw==
0x44: RA==
0x45: RQ==
0x46: Rg==
0x47: Rw==
0x48: SA==
0x49: SQ==
0x4A: Sg==
0x4B: Sw==
0x4C: TA==
0x4D: TQ==
0x4E: Tg==
0x4F: Tw==
0x50: UA==
0x51: UQ==
0x52: Ug==
0x53: Uw==
0x54: VA==
0x55: VQ==
0x56: Vg==
0x57: Vw==
0x58: WA==
0x59: WQ==
0x5A: Wg==
0x5B: Ww==
0x5C: XA==
0x5D: XQ==
0x5E: Xg==
0x5F: Xw==
0x60: YA==
0x61: YQ==
0x62: Yg==
0x63: Yw==
0x64: ZA==
0x65: ZQ==
0x66: Zg==
0x67: Zw==
0x68: aA==
0x69: aQ==
0x6A: ag==
0x6B: aw==
0x6C: bA==
0x6D: bQ==
0x6E: bg==
0x6F: bw==
0x70: cA==
0x71: cQ==
0x72: cg==
0x73: cw==
0x74: dA==
0x75: dQ==
0x76: dg==
0x77: dw==
0x78: eA==
0x79: eQ==
0x7A: eg==
0x7B: ew==
0x7C: fA==
0x7D: fQ==
0x7E: fg==
0x7F: fw==
0x80: gA==
0x81: gQ==
0x82: gg==
0x83: gw==
0x84: hA==
0x85: hQ==
0x86: hg==
0x87: hw==
0x88: iA==
0x89: iQ==
0x8A: ig==
0x8B: iw==
0x8C: jA==
0x8D: jQ==
0x8E: jg==
0x8F: jw==
0x90: kA==
0x91: kQ==
0x92: kg==
0x93: kw==
0x94: lA==
0x95: lQ==
0x96: lg==
0x97: lw==
0x98: mA==
0x99: mQ==
0x9A: mg==
0x9B: mw==
0x9C: nA==
0x9D: nQ==
0x9E: ng==
0x9F: nw==
0xA0: oA==
0xA1: oQ==
0xA2: og==
0xA3: ow==
0xA4: pA==
0xA5: pQ==
0xA6: pg==
0xA7: pw==
0xA8: qA==
0xA9: qQ==
0xAA: qg==
0xAB: qw==
0xAC: rA==
0xAD: rQ==
0xAE: rg==
0xAF: rw==
0xB0: sA==
0xB1: sQ==
0xB2: sg==
0xB3: sw==
0xB4: tA==
0xB5: tQ==
0xB6: tg==
0xB7: tw==
0xB8: uA==
0xB9: uQ==
0xBA: ug==
0xBB: uw==
0xBC: vA==
0xBD: vQ==
0xBE: vg==
0xBF: vw==
0xC0: wA==
0xC1: wQ==
0xC2: wg==
0xC3: ww==
0xC4: xA==
0xC5: xQ==
0xC6: xg==
0xC7: xw==
0xC8: yA==
0xC9: yQ==
0xCA: yg==
0xCB: yw==
0xCC: zA==
0xCD: zQ==
0xCE: zg==
0xCF: zw==
0xD0: 0A==
0xD1: 0Q==
0xD2: 0g==
0xD3: 0w==
0xD4: 1A==
0xD5: 1Q==
0xD6: 1g==
0xD7: 1w==
0xD8: 2A==
0xD9: 2Q==
0xDA: 2g==
0xDB: 2w==
0xDC: 3A==
0xDD: 3Q==
0xDE: 3g==
0xDF: 3w==
0xE0: 4A==
0xE1: 4Q==
0xE2: 4g==
0xE3: 4w==
0xE4: 5A==
0xE5: 5Q==
0xE6: 5g==
0xE7: 5w==
0xE8: 6A==
0xE9: 6Q==
0xEA: 6g==
0xEB: 6w==
0xEC: 7A==
0xED: 7Q==
0xEE: 7g==
0xEF: 7w==
0xF0: 8A==
0xF1: 8Q==
0xF2: 8g==
0xF3: 8w==
0xF4: 9A==
0xF5: 9Q==
0xF6: 9g==
0xF7: 9w==
0xF8: +A==
0xF9: +Q==
0xFA: +g==
0xFB: +w==
0xFC: /A==
0xFD: /Q==
0xFE: /g==
0xFF: /w==
Done

View file

@ -0,0 +1,37 @@
--TEST--
Test base64_encode() function : error conditions - wrong number of args
--FILE--
<?php
/* Prototype : proto string base64_encode(string str)
* Description: Encodes string using MIME base64 algorithm
* Source code: ext/standard/base64.c
* Alias to functions:
*/
echo "*** Testing base64_encode() : error conditions - wrong number of args ***\n";
// Zero arguments
echo "\n-- Testing base64_encode() function with Zero arguments --\n";
var_dump( base64_encode() );
//Test base64_encode with one more than the expected number of arguments
echo "\n-- Testing base64_encode() function with more than expected no. of arguments --\n";
$str = 'string_val';
$extra_arg = 10;
var_dump( base64_encode($str, $extra_arg) );
echo "Done";
?>
--EXPECTF--
*** Testing base64_encode() : error conditions - wrong number of args ***
-- Testing base64_encode() function with Zero arguments --
Warning: base64_encode() expects exactly 1 parameter, 0 given in %s on line 12
NULL
-- Testing base64_encode() function with more than expected no. of arguments --
Warning: base64_encode() expects exactly 1 parameter, 2 given in %s on line 18
NULL
Done

View file

@ -0,0 +1,167 @@
--TEST--
Test base64_encode() function : usage variations - unexpected types for argument 1
--FILE--
<?php
/* Prototype : proto string base64_encode(string str)
* Description: Encodes string using MIME base64 algorithm
* Source code: ext/standard/base64.c
* Alias to functions:
*/
echo "*** Testing base64_encode() : usage variations ***\n";
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');
// 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 str
foreach($values as $value) {
echo "\nArg value $value \n";
var_dump( base64_encode($value) );
};
echo "Done";
?>
--EXPECTF--
*** Testing base64_encode() : usage variations ***
Error: 8 - Undefined variable: undefined_var, %s(63)
Error: 8 - Undefined variable: unset_var, %s(66)
Arg value 0
string(4) "MA=="
Arg value 1
string(4) "MQ=="
Arg value 12345
string(8) "MTIzNDU="
Arg value -2345
string(8) "LTIzNDU="
Arg value 10.5
string(8) "MTAuNQ=="
Arg value -10.5
string(8) "LTEwLjU="
Arg value 101234567000
string(16) "MTAxMjM0NTY3MDAw"
Arg value 1.07654321E-9
string(20) "MS4wNzY1NDMyMUUtOQ=="
Arg value 0.5
string(4) "MC41"
Arg value Array
Error: 2 - base64_encode() expects parameter 1 to be string, array given, %s(73)
NULL
Arg value Array
Error: 2 - base64_encode() expects parameter 1 to be string, array given, %s(73)
NULL
Arg value Array
Error: 2 - base64_encode() expects parameter 1 to be string, array given, %s(73)
NULL
Arg value Array
Error: 2 - base64_encode() expects parameter 1 to be string, array given, %s(73)
NULL
Arg value Array
Error: 2 - base64_encode() expects parameter 1 to be string, array given, %s(73)
NULL
Arg value
string(0) ""
Arg value
string(0) ""
Arg value 1
string(4) "MQ=="
Arg value
string(0) ""
Arg value 1
string(4) "MQ=="
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(72)
Arg value
Error: 2 - base64_encode() expects parameter 1 to be string, object given, %s(73)
NULL
Arg value
string(0) ""
Arg value
string(0) ""
Done

View file

@ -0,0 +1,899 @@
--TEST--
Test parse_url() function: Parse a load of URLs without specifying the component
--FILE--
<?php
/* Prototype : proto mixed parse_url(string url, [int url_component])
* Description: Parse a and return its components
* Source code: ext/standard/url.c
* Alias to functions:
*/
/*
* Parse a load of URLs without specifying the component
*/
include_once(dirname(__FILE__) . '/urls.inc');
foreach ($urls as $url) {
echo "\n--> $url: ";
var_dump(parse_url($url));
}
echo "Done";
?>
--EXPECTF--
--> 64.246.30.37: array(1) {
["path"]=>
string(12) "64.246.30.37"
}
--> http://64.246.30.37: array(2) {
["scheme"]=>
string(4) "http"
["host"]=>
string(12) "64.246.30.37"
}
--> http://64.246.30.37/: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
string(12) "64.246.30.37"
["path"]=>
string(1) "/"
}
--> 64.246.30.37/: array(1) {
["path"]=>
string(13) "64.246.30.37/"
}
--> 64.246.30.37:80/: array(3) {
["host"]=>
string(12) "64.246.30.37"
["port"]=>
int(80)
["path"]=>
string(1) "/"
}
--> php.net: array(1) {
["path"]=>
string(7) "php.net"
}
--> php.net/: array(1) {
["path"]=>
string(8) "php.net/"
}
--> http://php.net: array(2) {
["scheme"]=>
string(4) "http"
["host"]=>
string(7) "php.net"
}
--> http://php.net/: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
string(7) "php.net"
["path"]=>
string(1) "/"
}
--> www.php.net: array(1) {
["path"]=>
string(11) "www.php.net"
}
--> www.php.net/: array(1) {
["path"]=>
string(12) "www.php.net/"
}
--> http://www.php.net: array(2) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
}
--> http://www.php.net/: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["path"]=>
string(1) "/"
}
--> www.php.net:80: array(2) {
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
}
--> http://www.php.net:80: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
}
--> http://www.php.net:80/: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(1) "/"
}
--> http://www.php.net/index.php: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["path"]=>
string(10) "/index.php"
}
--> www.php.net/?: array(1) {
["path"]=>
string(12) "www.php.net/"
}
--> www.php.net:80/?: array(3) {
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(1) "/"
}
--> http://www.php.net/?: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["path"]=>
string(1) "/"
}
--> http://www.php.net:80/?: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(1) "/"
}
--> http://www.php.net:80/index.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(10) "/index.php"
}
--> http://www.php.net:80/foo/bar/index.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(18) "/foo/bar/index.php"
}
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
}
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2&parameters=3&too=4&here=5: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
["query"]=>
string(37) "lots=1&of=2&parameters=3&too=4&here=5"
}
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(45) "/this/is/a/very/deep/directory/structure/and/"
}
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
}
--> http://www.php.net:80/this/../a/../deep/directory: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(28) "/this/../a/../deep/directory"
}
--> http://www.php.net:80/this/../a/../deep/directory/: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(29) "/this/../a/../deep/directory/"
}
--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(42) "/this/is/a/very/deep/directory/../file.php"
}
--> http://www.php.net:80/index.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(10) "/index.php"
}
--> http://www.php.net:80/index.php?: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(10) "/index.php"
}
--> http://www.php.net:80/#foo: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(1) "/"
["fragment"]=>
string(3) "foo"
}
--> http://www.php.net:80/?#: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(1) "/"
}
--> http://www.php.net:80/?test=1: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(1) "/"
["query"]=>
string(6) "test=1"
}
--> http://www.php.net/?test=1&: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["path"]=>
string(1) "/"
["query"]=>
string(7) "test=1&"
}
--> http://www.php.net:80/?&: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(1) "/"
["query"]=>
string(1) "&"
}
--> http://www.php.net:80/index.php?test=1&: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(10) "/index.php"
["query"]=>
string(7) "test=1&"
}
--> http://www.php.net/index.php?&: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["path"]=>
string(10) "/index.php"
["query"]=>
string(1) "&"
}
--> http://www.php.net:80/index.php?foo&: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(10) "/index.php"
["query"]=>
string(4) "foo&"
}
--> http://www.php.net/index.php?&foo: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["path"]=>
string(10) "/index.php"
["query"]=>
string(4) "&foo"
}
--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(10) "/index.php"
["query"]=>
string(31) "test=1&test2=char&test3=mixesCI"
}
--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(5) {
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["path"]=>
string(10) "/index.php"
["query"]=>
string(31) "test=1&test2=char&test3=mixesCI"
["fragment"]=>
string(16) "some_page_ref123"
}
--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["user"]=>
string(6) "secret"
["path"]=>
string(10) "/index.php"
["query"]=>
string(31) "test=1&test2=char&test3=mixesCI"
["fragment"]=>
string(16) "some_page_ref123"
}
--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(6) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["user"]=>
string(6) "secret"
["path"]=>
string(10) "/index.php"
["query"]=>
string(31) "test=1&test2=char&test3=mixesCI"
["fragment"]=>
string(16) "some_page_ref123"
}
--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["pass"]=>
string(7) "hideout"
["path"]=>
string(10) "/index.php"
["query"]=>
string(31) "test=1&test2=char&test3=mixesCI"
["fragment"]=>
string(16) "some_page_ref123"
}
--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["user"]=>
string(6) "secret"
["pass"]=>
string(7) "hideout"
["path"]=>
string(10) "/index.php"
["query"]=>
string(31) "test=1&test2=char&test3=mixesCI"
["fragment"]=>
string(16) "some_page_ref123"
}
--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["user"]=>
string(14) "secret@hideout"
["path"]=>
string(10) "/index.php"
["query"]=>
string(31) "test=1&test2=char&test3=mixesCI"
["fragment"]=>
string(16) "some_page_ref123"
}
--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["user"]=>
string(6) "secret"
["pass"]=>
string(7) "hid:out"
["path"]=>
string(10) "/index.php"
["query"]=>
string(31) "test=1&test2=char&test3=mixesCI"
["fragment"]=>
string(16) "some_page_ref123"
}
--> nntp://news.php.net: array(2) {
["scheme"]=>
string(4) "nntp"
["host"]=>
string(12) "news.php.net"
}
--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz: array(3) {
["scheme"]=>
string(3) "ftp"
["host"]=>
string(11) "ftp.gnu.org"
["path"]=>
string(22) "/gnu/glic/glibc.tar.gz"
}
--> zlib:http://foo@bar: array(2) {
["scheme"]=>
string(4) "zlib"
["path"]=>
string(14) "http://foo@bar"
}
--> zlib:filename.txt: array(2) {
["scheme"]=>
string(4) "zlib"
["path"]=>
string(12) "filename.txt"
}
--> zlib:/path/to/my/file/file.txt: array(2) {
["scheme"]=>
string(4) "zlib"
["path"]=>
string(25) "/path/to/my/file/file.txt"
}
--> foo://foo@bar: array(3) {
["scheme"]=>
string(3) "foo"
["host"]=>
string(3) "bar"
["user"]=>
string(3) "foo"
}
--> mailto:me@mydomain.com: array(2) {
["scheme"]=>
string(6) "mailto"
["path"]=>
string(15) "me@mydomain.com"
}
--> /foo.php?a=b&c=d: array(2) {
["path"]=>
string(8) "/foo.php"
["query"]=>
string(7) "a=b&c=d"
}
--> foo.php?a=b&c=d: array(2) {
["path"]=>
string(7) "foo.php"
["query"]=>
string(7) "a=b&c=d"
}
--> http://user:passwd@www.example.com:8080?bar=1&boom=0: array(6) {
["scheme"]=>
string(4) "http"
["host"]=>
string(15) "www.example.com"
["port"]=>
int(8080)
["user"]=>
string(4) "user"
["pass"]=>
string(6) "passwd"
["query"]=>
string(12) "bar=1&boom=0"
}
--> file:///path/to/file: array(2) {
["scheme"]=>
string(4) "file"
["path"]=>
string(13) "/path/to/file"
}
--> file://path/to/file: array(3) {
["scheme"]=>
string(4) "file"
["host"]=>
string(4) "path"
["path"]=>
string(8) "/to/file"
}
--> file:/path/to/file: array(2) {
["scheme"]=>
string(4) "file"
["path"]=>
string(13) "/path/to/file"
}
--> http://1.2.3.4:/abc.asp?a=1&b=2: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(7) "1.2.3.4"
["path"]=>
string(8) "/abc.asp"
["query"]=>
string(7) "a=1&b=2"
}
--> http://foo.com#bar: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
string(7) "foo.com"
["fragment"]=>
string(3) "bar"
}
--> scheme:: array(1) {
["scheme"]=>
string(6) "scheme"
}
--> foo+bar://baz@bang/bla: array(4) {
["scheme"]=>
string(7) "foo+bar"
["host"]=>
string(4) "bang"
["user"]=>
string(3) "baz"
["path"]=>
string(4) "/bla"
}
--> gg:9130731: array(2) {
["scheme"]=>
string(2) "gg"
["path"]=>
string(7) "9130731"
}
--> http://user:@pass@host/path?argument?value#etc: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
string(4) "host"
["user"]=>
string(4) "user"
["pass"]=>
string(5) "@pass"
["path"]=>
string(5) "/path"
["query"]=>
string(14) "argument?value"
["fragment"]=>
string(3) "etc"
}
--> http://10.10.10.10/:80: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "10.10.10.10"
["path"]=>
string(4) "/:80"
}
--> http://x:?: array(2) {
["scheme"]=>
string(4) "http"
["host"]=>
string(1) "x"
}
--> x:blah.com: array(2) {
["scheme"]=>
string(1) "x"
["path"]=>
string(8) "blah.com"
}
--> x:/blah.com: array(2) {
["scheme"]=>
string(1) "x"
["path"]=>
string(9) "/blah.com"
}
--> x://::abc/?: array(3) {
["scheme"]=>
string(1) "x"
["host"]=>
string(1) ":"
["path"]=>
string(1) "/"
}
--> http://::?: array(2) {
["scheme"]=>
string(4) "http"
["host"]=>
string(1) ":"
}
--> x://::6.5: array(3) {
["scheme"]=>
string(1) "x"
["host"]=>
string(1) ":"
["port"]=>
int(6)
}
--> http://?:/: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
string(1) "?"
["path"]=>
string(1) "/"
}
--> http://@?:/: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(1) "?"
["user"]=>
string(0) ""
["path"]=>
string(1) "/"
}
--> file:///:: array(2) {
["scheme"]=>
string(4) "file"
["path"]=>
string(2) "/:"
}
--> file:///a:/: array(2) {
["scheme"]=>
string(4) "file"
["path"]=>
string(3) "a:/"
}
--> file:///ab:/: array(2) {
["scheme"]=>
string(4) "file"
["path"]=>
string(5) "/ab:/"
}
--> file:///a:/: array(2) {
["scheme"]=>
string(4) "file"
["path"]=>
string(3) "a:/"
}
--> file:///@:/: array(2) {
["scheme"]=>
string(4) "file"
["path"]=>
string(3) "@:/"
}
--> file:///:80/: array(2) {
["scheme"]=>
string(4) "file"
["path"]=>
string(5) "/:80/"
}
--> []: array(1) {
["path"]=>
string(2) "[]"
}
--> http://[x:80]/: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
string(6) "[x:80]"
["path"]=>
string(1) "/"
}
--> : array(1) {
["path"]=>
string(0) ""
}
--> /: array(1) {
["path"]=>
string(1) "/"
}
--> http:///blah.com:
Warning: parse_url(http:///blah.com): Unable to parse URL in %s on line 15
bool(false)
--> http://:80:
Warning: parse_url(http://:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user@:80:
Warning: parse_url(http://user@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user:pass@:80:
Warning: parse_url(http://user:pass@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://::
Warning: parse_url(http://:): Unable to parse URL in %s on line 15
bool(false)
--> http://@/:
Warning: parse_url(http://@/): Unable to parse URL in %s on line 15
bool(false)
--> http://@:/:
Warning: parse_url(http://@:/): Unable to parse URL in %s on line 15
bool(false)
--> http://:/:
Warning: parse_url(http://:/): Unable to parse URL in %s on line 15
bool(false)
--> http://?:
Warning: parse_url(http://?): Unable to parse URL in %s on line 15
bool(false)
--> http://?::
Warning: parse_url(http://?:): Unable to parse URL in %s on line 15
bool(false)
--> http://:?:
Warning: parse_url(http://:?): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:123456:
Warning: parse_url(http://blah.com:123456): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:abcdef:
Warning: parse_url(http://blah.com:abcdef): Unable to parse URL in %s on line 15
bool(false)
Done

View file

@ -0,0 +1,151 @@
--TEST--
Test parse_url() function: Parse a load of URLs without specifying PHP_URL_SCHEME as the URL component
--FILE--
<?php
/* Prototype : proto mixed parse_url(string url, [int url_component])
* Description: Parse a URL and return its components
* Source code: ext/standard/url.c
* Alias to functions:
*/
/*
* Parse a load of URLs without specifying PHP_URL_SCHEME as the URL component
*/
include_once(dirname(__FILE__) . '/urls.inc');
foreach ($urls as $url) {
echo "--> $url : ";
var_dump(parse_url($url, PHP_URL_SCHEME));
}
echo "Done";
?>
--EXPECTF--
--> 64.246.30.37 : NULL
--> http://64.246.30.37 : string(4) "http"
--> http://64.246.30.37/ : string(4) "http"
--> 64.246.30.37/ : NULL
--> 64.246.30.37:80/ : NULL
--> php.net : NULL
--> php.net/ : NULL
--> http://php.net : string(4) "http"
--> http://php.net/ : string(4) "http"
--> www.php.net : NULL
--> www.php.net/ : NULL
--> http://www.php.net : string(4) "http"
--> http://www.php.net/ : string(4) "http"
--> www.php.net:80 : NULL
--> http://www.php.net:80 : string(4) "http"
--> http://www.php.net:80/ : string(4) "http"
--> http://www.php.net/index.php : string(4) "http"
--> www.php.net/? : NULL
--> www.php.net:80/? : NULL
--> http://www.php.net/? : string(4) "http"
--> http://www.php.net:80/? : string(4) "http"
--> http://www.php.net:80/index.php : string(4) "http"
--> http://www.php.net:80/foo/bar/index.php : string(4) "http"
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : string(4) "http"
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2&parameters=3&too=4&here=5 : string(4) "http"
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/ : string(4) "http"
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : string(4) "http"
--> http://www.php.net:80/this/../a/../deep/directory : string(4) "http"
--> http://www.php.net:80/this/../a/../deep/directory/ : string(4) "http"
--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php : string(4) "http"
--> http://www.php.net:80/index.php : string(4) "http"
--> http://www.php.net:80/index.php? : string(4) "http"
--> http://www.php.net:80/#foo : string(4) "http"
--> http://www.php.net:80/?# : string(4) "http"
--> http://www.php.net:80/?test=1 : string(4) "http"
--> http://www.php.net/?test=1& : string(4) "http"
--> http://www.php.net:80/?& : string(4) "http"
--> http://www.php.net:80/index.php?test=1& : string(4) "http"
--> http://www.php.net/index.php?& : string(4) "http"
--> http://www.php.net:80/index.php?foo& : string(4) "http"
--> http://www.php.net/index.php?&foo : string(4) "http"
--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : string(4) "http"
--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(4) "http"
--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(4) "http"
--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(4) "http"
--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(4) "http"
--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(4) "http"
--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(4) "http"
--> nntp://news.php.net : string(4) "nntp"
--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz : string(3) "ftp"
--> zlib:http://foo@bar : string(4) "zlib"
--> zlib:filename.txt : string(4) "zlib"
--> zlib:/path/to/my/file/file.txt : string(4) "zlib"
--> foo://foo@bar : string(3) "foo"
--> mailto:me@mydomain.com : string(6) "mailto"
--> /foo.php?a=b&c=d : NULL
--> foo.php?a=b&c=d : NULL
--> http://user:passwd@www.example.com:8080?bar=1&boom=0 : string(4) "http"
--> file:///path/to/file : string(4) "file"
--> file://path/to/file : string(4) "file"
--> file:/path/to/file : string(4) "file"
--> http://1.2.3.4:/abc.asp?a=1&b=2 : string(4) "http"
--> http://foo.com#bar : string(4) "http"
--> scheme: : string(6) "scheme"
--> foo+bar://baz@bang/bla : string(7) "foo+bar"
--> gg:9130731 : string(2) "gg"
--> http://user:@pass@host/path?argument?value#etc : string(4) "http"
--> http://10.10.10.10/:80 : string(4) "http"
--> http://x:? : string(4) "http"
--> x:blah.com : string(1) "x"
--> x:/blah.com : string(1) "x"
--> x://::abc/? : string(1) "x"
--> http://::? : string(4) "http"
--> x://::6.5 : string(1) "x"
--> http://?:/ : string(4) "http"
--> http://@?:/ : string(4) "http"
--> file:///: : string(4) "file"
--> file:///a:/ : string(4) "file"
--> file:///ab:/ : string(4) "file"
--> file:///a:/ : string(4) "file"
--> file:///@:/ : string(4) "file"
--> file:///:80/ : string(4) "file"
--> [] : NULL
--> http://[x:80]/ : string(4) "http"
--> : NULL
--> / : NULL
--> http:///blah.com :
Warning: parse_url(http:///blah.com): Unable to parse URL in %s on line 15
bool(false)
--> http://:80 :
Warning: parse_url(http://:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user@:80 :
Warning: parse_url(http://user@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user:pass@:80 :
Warning: parse_url(http://user:pass@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://: :
Warning: parse_url(http://:): Unable to parse URL in %s on line 15
bool(false)
--> http://@/ :
Warning: parse_url(http://@/): Unable to parse URL in %s on line 15
bool(false)
--> http://@:/ :
Warning: parse_url(http://@:/): Unable to parse URL in %s on line 15
bool(false)
--> http://:/ :
Warning: parse_url(http://:/): Unable to parse URL in %s on line 15
bool(false)
--> http://? :
Warning: parse_url(http://?): Unable to parse URL in %s on line 15
bool(false)
--> http://?: :
Warning: parse_url(http://?:): Unable to parse URL in %s on line 15
bool(false)
--> http://:? :
Warning: parse_url(http://:?): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:123456 :
Warning: parse_url(http://blah.com:123456): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:abcdef :
Warning: parse_url(http://blah.com:abcdef): Unable to parse URL in %s on line 15
bool(false)
Done

View file

@ -0,0 +1,150 @@
--TEST--
Test parse_url() function: Parse a load of URLs without specifying PHP_URL_HOST as the URL component
--FILE--
<?php
/* Prototype : proto mixed parse_url(string url, [int url_component])
* Description: Parse a URL and return its components
* Source code: ext/standard/url.c
* Alias to functions:
*/
/*
* Parse a load of URLs without specifying PHP_URL_HOST as the URL component
*/
include_once(dirname(__FILE__) . '/urls.inc');
foreach ($urls as $url) {
echo "--> $url : ";
var_dump(parse_url($url, PHP_URL_HOST));
}
echo "Done";
?>
--EXPECTF--
--> 64.246.30.37 : NULL
--> http://64.246.30.37 : string(12) "64.246.30.37"
--> http://64.246.30.37/ : string(12) "64.246.30.37"
--> 64.246.30.37/ : NULL
--> 64.246.30.37:80/ : string(12) "64.246.30.37"
--> php.net : NULL
--> php.net/ : NULL
--> http://php.net : string(7) "php.net"
--> http://php.net/ : string(7) "php.net"
--> www.php.net : NULL
--> www.php.net/ : NULL
--> http://www.php.net : string(11) "www.php.net"
--> http://www.php.net/ : string(11) "www.php.net"
--> www.php.net:80 : string(11) "www.php.net"
--> http://www.php.net:80 : string(11) "www.php.net"
--> http://www.php.net:80/ : string(11) "www.php.net"
--> http://www.php.net/index.php : string(11) "www.php.net"
--> www.php.net/? : NULL
--> www.php.net:80/? : string(11) "www.php.net"
--> http://www.php.net/? : string(11) "www.php.net"
--> http://www.php.net:80/? : string(11) "www.php.net"
--> http://www.php.net:80/index.php : string(11) "www.php.net"
--> http://www.php.net:80/foo/bar/index.php : string(11) "www.php.net"
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : string(11) "www.php.net"
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2&parameters=3&too=4&here=5 : string(11) "www.php.net"
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/ : string(11) "www.php.net"
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : string(11) "www.php.net"
--> http://www.php.net:80/this/../a/../deep/directory : string(11) "www.php.net"
--> http://www.php.net:80/this/../a/../deep/directory/ : string(11) "www.php.net"
--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php : string(11) "www.php.net"
--> http://www.php.net:80/index.php : string(11) "www.php.net"
--> http://www.php.net:80/index.php? : string(11) "www.php.net"
--> http://www.php.net:80/#foo : string(11) "www.php.net"
--> http://www.php.net:80/?# : string(11) "www.php.net"
--> http://www.php.net:80/?test=1 : string(11) "www.php.net"
--> http://www.php.net/?test=1& : string(11) "www.php.net"
--> http://www.php.net:80/?& : string(11) "www.php.net"
--> http://www.php.net:80/index.php?test=1& : string(11) "www.php.net"
--> http://www.php.net/index.php?& : string(11) "www.php.net"
--> http://www.php.net:80/index.php?foo& : string(11) "www.php.net"
--> http://www.php.net/index.php?&foo : string(11) "www.php.net"
--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : string(11) "www.php.net"
--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(11) "www.php.net"
--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(11) "www.php.net"
--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(11) "www.php.net"
--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(11) "www.php.net"
--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(11) "www.php.net"
--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(11) "www.php.net"
--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(11) "www.php.net"
--> nntp://news.php.net : string(12) "news.php.net"
--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz : string(11) "ftp.gnu.org"
--> zlib:http://foo@bar : NULL
--> zlib:filename.txt : NULL
--> zlib:/path/to/my/file/file.txt : NULL
--> foo://foo@bar : string(3) "bar"
--> mailto:me@mydomain.com : NULL
--> /foo.php?a=b&c=d : NULL
--> foo.php?a=b&c=d : NULL
--> http://user:passwd@www.example.com:8080?bar=1&boom=0 : string(15) "www.example.com"
--> file:///path/to/file : NULL
--> file://path/to/file : string(4) "path"
--> file:/path/to/file : NULL
--> http://1.2.3.4:/abc.asp?a=1&b=2 : string(7) "1.2.3.4"
--> http://foo.com#bar : string(7) "foo.com"
--> scheme: : NULL
--> foo+bar://baz@bang/bla : string(4) "bang"
--> gg:9130731 : NULL
--> http://user:@pass@host/path?argument?value#etc : string(4) "host"
--> http://10.10.10.10/:80 : string(11) "10.10.10.10"
--> http://x:? : string(1) "x"
--> x:blah.com : NULL
--> x:/blah.com : NULL
--> x://::abc/? : string(1) ":"
--> http://::? : string(1) ":"
--> x://::6.5 : string(1) ":"
--> http://?:/ : string(1) "?"
--> http://@?:/ : string(1) "?"
--> file:///: : NULL
--> file:///a:/ : NULL
--> file:///ab:/ : NULL
--> file:///a:/ : NULL
--> file:///@:/ : NULL
--> file:///:80/ : NULL
--> [] : NULL
--> http://[x:80]/ : string(6) "[x:80]"
--> : NULL
--> / : NULL
--> http:///blah.com :
Warning: parse_url(http:///blah.com): Unable to parse URL in %s on line 15
bool(false)
--> http://:80 :
Warning: parse_url(http://:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user@:80 :
Warning: parse_url(http://user@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user:pass@:80 :
Warning: parse_url(http://user:pass@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://: :
Warning: parse_url(http://:): Unable to parse URL in %s on line 15
bool(false)
--> http://@/ :
Warning: parse_url(http://@/): Unable to parse URL in %s on line 15
bool(false)
--> http://@:/ :
Warning: parse_url(http://@:/): Unable to parse URL in %s on line 15
bool(false)
--> http://:/ :
Warning: parse_url(http://:/): Unable to parse URL in %s on line 15
bool(false)
--> http://? :
Warning: parse_url(http://?): Unable to parse URL in %s on line 15
bool(false)
--> http://?: :
Warning: parse_url(http://?:): Unable to parse URL in %s on line 15
bool(false)
--> http://:? :
Warning: parse_url(http://:?): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:123456 :
Warning: parse_url(http://blah.com:123456): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:abcdef :
Warning: parse_url(http://blah.com:abcdef): Unable to parse URL in %s on line 15
bool(false)
Done

View file

@ -0,0 +1,150 @@
--TEST--
Test parse_url() function: Parse a load of URLs without specifying PHP_URL_PORT as the URL component
--FILE--
<?php
/* Prototype : proto mixed parse_url(string url, [int url_component])
* Description: Parse a URL and return its components
* Source code: ext/standard/url.c
* Alias to functions:
*/
/*
* Parse a load of URLs without specifying PHP_URL_PORT as the URL component
*/
include_once(dirname(__FILE__) . '/urls.inc');
foreach ($urls as $url) {
echo "--> $url : ";
var_dump(parse_url($url, PHP_URL_PORT));
}
echo "Done";
?>
--EXPECTF--
--> 64.246.30.37 : NULL
--> http://64.246.30.37 : NULL
--> http://64.246.30.37/ : NULL
--> 64.246.30.37/ : NULL
--> 64.246.30.37:80/ : int(80)
--> php.net : NULL
--> php.net/ : NULL
--> http://php.net : NULL
--> http://php.net/ : NULL
--> www.php.net : NULL
--> www.php.net/ : NULL
--> http://www.php.net : NULL
--> http://www.php.net/ : NULL
--> www.php.net:80 : int(80)
--> http://www.php.net:80 : int(80)
--> http://www.php.net:80/ : int(80)
--> http://www.php.net/index.php : NULL
--> www.php.net/? : NULL
--> www.php.net:80/? : int(80)
--> http://www.php.net/? : NULL
--> http://www.php.net:80/? : int(80)
--> http://www.php.net:80/index.php : int(80)
--> http://www.php.net:80/foo/bar/index.php : int(80)
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : int(80)
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2&parameters=3&too=4&here=5 : int(80)
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/ : int(80)
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : int(80)
--> http://www.php.net:80/this/../a/../deep/directory : int(80)
--> http://www.php.net:80/this/../a/../deep/directory/ : int(80)
--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php : int(80)
--> http://www.php.net:80/index.php : int(80)
--> http://www.php.net:80/index.php? : int(80)
--> http://www.php.net:80/#foo : int(80)
--> http://www.php.net:80/?# : int(80)
--> http://www.php.net:80/?test=1 : int(80)
--> http://www.php.net/?test=1& : NULL
--> http://www.php.net:80/?& : int(80)
--> http://www.php.net:80/index.php?test=1& : int(80)
--> http://www.php.net/index.php?& : NULL
--> http://www.php.net:80/index.php?foo& : int(80)
--> http://www.php.net/index.php?&foo : NULL
--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : int(80)
--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : int(80)
--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : int(80)
--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : int(80)
--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : int(80)
--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : int(80)
--> nntp://news.php.net : NULL
--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz : NULL
--> zlib:http://foo@bar : NULL
--> zlib:filename.txt : NULL
--> zlib:/path/to/my/file/file.txt : NULL
--> foo://foo@bar : NULL
--> mailto:me@mydomain.com : NULL
--> /foo.php?a=b&c=d : NULL
--> foo.php?a=b&c=d : NULL
--> http://user:passwd@www.example.com:8080?bar=1&boom=0 : int(8080)
--> file:///path/to/file : NULL
--> file://path/to/file : NULL
--> file:/path/to/file : NULL
--> http://1.2.3.4:/abc.asp?a=1&b=2 : NULL
--> http://foo.com#bar : NULL
--> scheme: : NULL
--> foo+bar://baz@bang/bla : NULL
--> gg:9130731 : NULL
--> http://user:@pass@host/path?argument?value#etc : NULL
--> http://10.10.10.10/:80 : NULL
--> http://x:? : NULL
--> x:blah.com : NULL
--> x:/blah.com : NULL
--> x://::abc/? : NULL
--> http://::? : NULL
--> x://::6.5 : int(6)
--> http://?:/ : NULL
--> http://@?:/ : NULL
--> file:///: : NULL
--> file:///a:/ : NULL
--> file:///ab:/ : NULL
--> file:///a:/ : NULL
--> file:///@:/ : NULL
--> file:///:80/ : NULL
--> [] : NULL
--> http://[x:80]/ : NULL
--> : NULL
--> / : NULL
--> http:///blah.com :
Warning: parse_url(http:///blah.com): Unable to parse URL in %s on line 15
bool(false)
--> http://:80 :
Warning: parse_url(http://:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user@:80 :
Warning: parse_url(http://user@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user:pass@:80 :
Warning: parse_url(http://user:pass@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://: :
Warning: parse_url(http://:): Unable to parse URL in %s on line 15
bool(false)
--> http://@/ :
Warning: parse_url(http://@/): Unable to parse URL in %s on line 15
bool(false)
--> http://@:/ :
Warning: parse_url(http://@:/): Unable to parse URL in %s on line 15
bool(false)
--> http://:/ :
Warning: parse_url(http://:/): Unable to parse URL in %s on line 15
bool(false)
--> http://? :
Warning: parse_url(http://?): Unable to parse URL in %s on line 15
bool(false)
--> http://?: :
Warning: parse_url(http://?:): Unable to parse URL in %s on line 15
bool(false)
--> http://:? :
Warning: parse_url(http://:?): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:123456 :
Warning: parse_url(http://blah.com:123456): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:abcdef :
Warning: parse_url(http://blah.com:abcdef): Unable to parse URL in %s on line 15
bool(false)
Done

View file

@ -0,0 +1,150 @@
--TEST--
Test parse_url() function: Parse a load of URLs without specifying PHP_URL_USER as the URL component
--FILE--
<?php
/* Prototype : proto mixed parse_url(string url, [int url_component])
* Description: Parse a URL and return its components
* Source code: ext/standard/url.c
* Alias to functions:
*/
/*
* Parse a load of URLs without specifying PHP_URL_USER as the URL component
*/
include_once(dirname(__FILE__) . '/urls.inc');
foreach ($urls as $url) {
echo "--> $url : ";
var_dump(parse_url($url, PHP_URL_USER));
}
echo "Done";
?>
--EXPECTF--
--> 64.246.30.37 : NULL
--> http://64.246.30.37 : NULL
--> http://64.246.30.37/ : NULL
--> 64.246.30.37/ : NULL
--> 64.246.30.37:80/ : NULL
--> php.net : NULL
--> php.net/ : NULL
--> http://php.net : NULL
--> http://php.net/ : NULL
--> www.php.net : NULL
--> www.php.net/ : NULL
--> http://www.php.net : NULL
--> http://www.php.net/ : NULL
--> www.php.net:80 : NULL
--> http://www.php.net:80 : NULL
--> http://www.php.net:80/ : NULL
--> http://www.php.net/index.php : NULL
--> www.php.net/? : NULL
--> www.php.net:80/? : NULL
--> http://www.php.net/? : NULL
--> http://www.php.net:80/? : NULL
--> http://www.php.net:80/index.php : NULL
--> http://www.php.net:80/foo/bar/index.php : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2&parameters=3&too=4&here=5 : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/ : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : NULL
--> http://www.php.net:80/this/../a/../deep/directory : NULL
--> http://www.php.net:80/this/../a/../deep/directory/ : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php : NULL
--> http://www.php.net:80/index.php : NULL
--> http://www.php.net:80/index.php? : NULL
--> http://www.php.net:80/#foo : NULL
--> http://www.php.net:80/?# : NULL
--> http://www.php.net:80/?test=1 : NULL
--> http://www.php.net/?test=1& : NULL
--> http://www.php.net:80/?& : NULL
--> http://www.php.net:80/index.php?test=1& : NULL
--> http://www.php.net/index.php?& : NULL
--> http://www.php.net:80/index.php?foo& : NULL
--> http://www.php.net/index.php?&foo : NULL
--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : NULL
--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(6) "secret"
--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(6) "secret"
--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(6) "secret"
--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(14) "secret@hideout"
--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(6) "secret"
--> nntp://news.php.net : NULL
--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz : NULL
--> zlib:http://foo@bar : NULL
--> zlib:filename.txt : NULL
--> zlib:/path/to/my/file/file.txt : NULL
--> foo://foo@bar : string(3) "foo"
--> mailto:me@mydomain.com : NULL
--> /foo.php?a=b&c=d : NULL
--> foo.php?a=b&c=d : NULL
--> http://user:passwd@www.example.com:8080?bar=1&boom=0 : string(4) "user"
--> file:///path/to/file : NULL
--> file://path/to/file : NULL
--> file:/path/to/file : NULL
--> http://1.2.3.4:/abc.asp?a=1&b=2 : NULL
--> http://foo.com#bar : NULL
--> scheme: : NULL
--> foo+bar://baz@bang/bla : string(3) "baz"
--> gg:9130731 : NULL
--> http://user:@pass@host/path?argument?value#etc : string(4) "user"
--> http://10.10.10.10/:80 : NULL
--> http://x:? : NULL
--> x:blah.com : NULL
--> x:/blah.com : NULL
--> x://::abc/? : NULL
--> http://::? : NULL
--> x://::6.5 : NULL
--> http://?:/ : NULL
--> http://@?:/ : string(0) ""
--> file:///: : NULL
--> file:///a:/ : NULL
--> file:///ab:/ : NULL
--> file:///a:/ : NULL
--> file:///@:/ : NULL
--> file:///:80/ : NULL
--> [] : NULL
--> http://[x:80]/ : NULL
--> : NULL
--> / : NULL
--> http:///blah.com :
Warning: parse_url(http:///blah.com): Unable to parse URL in %s on line 15
bool(false)
--> http://:80 :
Warning: parse_url(http://:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user@:80 :
Warning: parse_url(http://user@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user:pass@:80 :
Warning: parse_url(http://user:pass@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://: :
Warning: parse_url(http://:): Unable to parse URL in %s on line 15
bool(false)
--> http://@/ :
Warning: parse_url(http://@/): Unable to parse URL in %s on line 15
bool(false)
--> http://@:/ :
Warning: parse_url(http://@:/): Unable to parse URL in %s on line 15
bool(false)
--> http://:/ :
Warning: parse_url(http://:/): Unable to parse URL in %s on line 15
bool(false)
--> http://? :
Warning: parse_url(http://?): Unable to parse URL in %s on line 15
bool(false)
--> http://?: :
Warning: parse_url(http://?:): Unable to parse URL in %s on line 15
bool(false)
--> http://:? :
Warning: parse_url(http://:?): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:123456 :
Warning: parse_url(http://blah.com:123456): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:abcdef :
Warning: parse_url(http://blah.com:abcdef): Unable to parse URL in %s on line 15
bool(false)
Done

View file

@ -0,0 +1,150 @@
--TEST--
Test parse_url() function: Parse a load of URLs without specifying PHP_URL_PASS as the URL component
--FILE--
<?php
/* Prototype : proto mixed parse_url(string url, [int url_component])
* Description: Parse a URL and return its components
* Source code: ext/standard/url.c
* Alias to functions:
*/
/*
* Parse a load of URLs without specifying PHP_URL_PASS as the URL component
*/
include_once(dirname(__FILE__) . '/urls.inc');
foreach ($urls as $url) {
echo "--> $url : ";
var_dump(parse_url($url, PHP_URL_PASS));
}
echo "Done";
?>
--EXPECTF--
--> 64.246.30.37 : NULL
--> http://64.246.30.37 : NULL
--> http://64.246.30.37/ : NULL
--> 64.246.30.37/ : NULL
--> 64.246.30.37:80/ : NULL
--> php.net : NULL
--> php.net/ : NULL
--> http://php.net : NULL
--> http://php.net/ : NULL
--> www.php.net : NULL
--> www.php.net/ : NULL
--> http://www.php.net : NULL
--> http://www.php.net/ : NULL
--> www.php.net:80 : NULL
--> http://www.php.net:80 : NULL
--> http://www.php.net:80/ : NULL
--> http://www.php.net/index.php : NULL
--> www.php.net/? : NULL
--> www.php.net:80/? : NULL
--> http://www.php.net/? : NULL
--> http://www.php.net:80/? : NULL
--> http://www.php.net:80/index.php : NULL
--> http://www.php.net:80/foo/bar/index.php : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2&parameters=3&too=4&here=5 : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/ : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : NULL
--> http://www.php.net:80/this/../a/../deep/directory : NULL
--> http://www.php.net:80/this/../a/../deep/directory/ : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php : NULL
--> http://www.php.net:80/index.php : NULL
--> http://www.php.net:80/index.php? : NULL
--> http://www.php.net:80/#foo : NULL
--> http://www.php.net:80/?# : NULL
--> http://www.php.net:80/?test=1 : NULL
--> http://www.php.net/?test=1& : NULL
--> http://www.php.net:80/?& : NULL
--> http://www.php.net:80/index.php?test=1& : NULL
--> http://www.php.net/index.php?& : NULL
--> http://www.php.net:80/index.php?foo& : NULL
--> http://www.php.net/index.php?&foo : NULL
--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : NULL
--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(7) "hideout"
--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(7) "hideout"
--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(7) "hid:out"
--> nntp://news.php.net : NULL
--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz : NULL
--> zlib:http://foo@bar : NULL
--> zlib:filename.txt : NULL
--> zlib:/path/to/my/file/file.txt : NULL
--> foo://foo@bar : NULL
--> mailto:me@mydomain.com : NULL
--> /foo.php?a=b&c=d : NULL
--> foo.php?a=b&c=d : NULL
--> http://user:passwd@www.example.com:8080?bar=1&boom=0 : string(6) "passwd"
--> file:///path/to/file : NULL
--> file://path/to/file : NULL
--> file:/path/to/file : NULL
--> http://1.2.3.4:/abc.asp?a=1&b=2 : NULL
--> http://foo.com#bar : NULL
--> scheme: : NULL
--> foo+bar://baz@bang/bla : NULL
--> gg:9130731 : NULL
--> http://user:@pass@host/path?argument?value#etc : string(5) "@pass"
--> http://10.10.10.10/:80 : NULL
--> http://x:? : NULL
--> x:blah.com : NULL
--> x:/blah.com : NULL
--> x://::abc/? : NULL
--> http://::? : NULL
--> x://::6.5 : NULL
--> http://?:/ : NULL
--> http://@?:/ : NULL
--> file:///: : NULL
--> file:///a:/ : NULL
--> file:///ab:/ : NULL
--> file:///a:/ : NULL
--> file:///@:/ : NULL
--> file:///:80/ : NULL
--> [] : NULL
--> http://[x:80]/ : NULL
--> : NULL
--> / : NULL
--> http:///blah.com :
Warning: parse_url(http:///blah.com): Unable to parse URL in %s on line 15
bool(false)
--> http://:80 :
Warning: parse_url(http://:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user@:80 :
Warning: parse_url(http://user@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user:pass@:80 :
Warning: parse_url(http://user:pass@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://: :
Warning: parse_url(http://:): Unable to parse URL in %s on line 15
bool(false)
--> http://@/ :
Warning: parse_url(http://@/): Unable to parse URL in %s on line 15
bool(false)
--> http://@:/ :
Warning: parse_url(http://@:/): Unable to parse URL in %s on line 15
bool(false)
--> http://:/ :
Warning: parse_url(http://:/): Unable to parse URL in %s on line 15
bool(false)
--> http://? :
Warning: parse_url(http://?): Unable to parse URL in %s on line 15
bool(false)
--> http://?: :
Warning: parse_url(http://?:): Unable to parse URL in %s on line 15
bool(false)
--> http://:? :
Warning: parse_url(http://:?): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:123456 :
Warning: parse_url(http://blah.com:123456): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:abcdef :
Warning: parse_url(http://blah.com:abcdef): Unable to parse URL in %s on line 15
bool(false)
Done

View file

@ -0,0 +1,150 @@
--TEST--
Test parse_url() function: Parse a load of URLs without specifying PHP_URL_PATH as the URL component
--FILE--
<?php
/* Prototype : proto mixed parse_url(string url, [int url_component])
* Description: Parse a URL and return its components
* Source code: ext/standard/url.c
* Alias to functions:
*/
/*
* Parse a load of URLs without specifying PHP_URL_PATH as the URL component
*/
include_once(dirname(__FILE__) . '/urls.inc');
foreach ($urls as $url) {
echo "--> $url : ";
var_dump(parse_url($url, PHP_URL_PATH));
}
echo "Done";
?>
--EXPECTF--
--> 64.246.30.37 : string(12) "64.246.30.37"
--> http://64.246.30.37 : NULL
--> http://64.246.30.37/ : string(1) "/"
--> 64.246.30.37/ : string(13) "64.246.30.37/"
--> 64.246.30.37:80/ : string(1) "/"
--> php.net : string(7) "php.net"
--> php.net/ : string(8) "php.net/"
--> http://php.net : NULL
--> http://php.net/ : string(1) "/"
--> www.php.net : string(11) "www.php.net"
--> www.php.net/ : string(12) "www.php.net/"
--> http://www.php.net : NULL
--> http://www.php.net/ : string(1) "/"
--> www.php.net:80 : NULL
--> http://www.php.net:80 : NULL
--> http://www.php.net:80/ : string(1) "/"
--> http://www.php.net/index.php : string(10) "/index.php"
--> www.php.net/? : string(12) "www.php.net/"
--> www.php.net:80/? : string(1) "/"
--> http://www.php.net/? : string(1) "/"
--> http://www.php.net:80/? : string(1) "/"
--> http://www.php.net:80/index.php : string(10) "/index.php"
--> http://www.php.net:80/foo/bar/index.php : string(18) "/foo/bar/index.php"
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2&parameters=3&too=4&here=5 : string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/ : string(45) "/this/is/a/very/deep/directory/structure/and/"
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
--> http://www.php.net:80/this/../a/../deep/directory : string(28) "/this/../a/../deep/directory"
--> http://www.php.net:80/this/../a/../deep/directory/ : string(29) "/this/../a/../deep/directory/"
--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php : string(42) "/this/is/a/very/deep/directory/../file.php"
--> http://www.php.net:80/index.php : string(10) "/index.php"
--> http://www.php.net:80/index.php? : string(10) "/index.php"
--> http://www.php.net:80/#foo : string(1) "/"
--> http://www.php.net:80/?# : string(1) "/"
--> http://www.php.net:80/?test=1 : string(1) "/"
--> http://www.php.net/?test=1& : string(1) "/"
--> http://www.php.net:80/?& : string(1) "/"
--> http://www.php.net:80/index.php?test=1& : string(10) "/index.php"
--> http://www.php.net/index.php?& : string(10) "/index.php"
--> http://www.php.net:80/index.php?foo& : string(10) "/index.php"
--> http://www.php.net/index.php?&foo : string(10) "/index.php"
--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : string(10) "/index.php"
--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(10) "/index.php"
--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(10) "/index.php"
--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(10) "/index.php"
--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(10) "/index.php"
--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(10) "/index.php"
--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(10) "/index.php"
--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(10) "/index.php"
--> nntp://news.php.net : NULL
--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz : string(22) "/gnu/glic/glibc.tar.gz"
--> zlib:http://foo@bar : string(14) "http://foo@bar"
--> zlib:filename.txt : string(12) "filename.txt"
--> zlib:/path/to/my/file/file.txt : string(25) "/path/to/my/file/file.txt"
--> foo://foo@bar : NULL
--> mailto:me@mydomain.com : string(15) "me@mydomain.com"
--> /foo.php?a=b&c=d : string(8) "/foo.php"
--> foo.php?a=b&c=d : string(7) "foo.php"
--> http://user:passwd@www.example.com:8080?bar=1&boom=0 : NULL
--> file:///path/to/file : string(13) "/path/to/file"
--> file://path/to/file : string(8) "/to/file"
--> file:/path/to/file : string(13) "/path/to/file"
--> http://1.2.3.4:/abc.asp?a=1&b=2 : string(8) "/abc.asp"
--> http://foo.com#bar : NULL
--> scheme: : NULL
--> foo+bar://baz@bang/bla : string(4) "/bla"
--> gg:9130731 : string(7) "9130731"
--> http://user:@pass@host/path?argument?value#etc : string(5) "/path"
--> http://10.10.10.10/:80 : string(4) "/:80"
--> http://x:? : NULL
--> x:blah.com : string(8) "blah.com"
--> x:/blah.com : string(9) "/blah.com"
--> x://::abc/? : string(1) "/"
--> http://::? : NULL
--> x://::6.5 : NULL
--> http://?:/ : string(1) "/"
--> http://@?:/ : string(1) "/"
--> file:///: : string(2) "/:"
--> file:///a:/ : string(3) "a:/"
--> file:///ab:/ : string(5) "/ab:/"
--> file:///a:/ : string(3) "a:/"
--> file:///@:/ : string(3) "@:/"
--> file:///:80/ : string(5) "/:80/"
--> [] : string(2) "[]"
--> http://[x:80]/ : string(1) "/"
--> : string(0) ""
--> / : string(1) "/"
--> http:///blah.com :
Warning: parse_url(http:///blah.com): Unable to parse URL in %s on line 15
bool(false)
--> http://:80 :
Warning: parse_url(http://:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user@:80 :
Warning: parse_url(http://user@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user:pass@:80 :
Warning: parse_url(http://user:pass@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://: :
Warning: parse_url(http://:): Unable to parse URL in %s on line 15
bool(false)
--> http://@/ :
Warning: parse_url(http://@/): Unable to parse URL in %s on line 15
bool(false)
--> http://@:/ :
Warning: parse_url(http://@:/): Unable to parse URL in %s on line 15
bool(false)
--> http://:/ :
Warning: parse_url(http://:/): Unable to parse URL in %s on line 15
bool(false)
--> http://? :
Warning: parse_url(http://?): Unable to parse URL in %s on line 15
bool(false)
--> http://?: :
Warning: parse_url(http://?:): Unable to parse URL in %s on line 15
bool(false)
--> http://:? :
Warning: parse_url(http://:?): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:123456 :
Warning: parse_url(http://blah.com:123456): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:abcdef :
Warning: parse_url(http://blah.com:abcdef): Unable to parse URL in %s on line 15
bool(false)
Done

View file

@ -0,0 +1,150 @@
--TEST--
Test parse_url() function: Parse a load of URLs without specifying PHP_URL_QUERY as the URL component
--FILE--
<?php
/* Prototype : proto mixed parse_url(string url, [int url_component])
* Description: Parse a URL and return its components
* Source code: ext/standard/url.c
* Alias to functions:
*/
/*
* Parse a load of URLs without specifying PHP_URL_QUERY as the URL component
*/
include_once(dirname(__FILE__) . '/urls.inc');
foreach ($urls as $url) {
echo "--> $url : ";
var_dump(parse_url($url, PHP_URL_QUERY));
}
echo "Done";
?>
--EXPECTF--
--> 64.246.30.37 : NULL
--> http://64.246.30.37 : NULL
--> http://64.246.30.37/ : NULL
--> 64.246.30.37/ : NULL
--> 64.246.30.37:80/ : NULL
--> php.net : NULL
--> php.net/ : NULL
--> http://php.net : NULL
--> http://php.net/ : NULL
--> www.php.net : NULL
--> www.php.net/ : NULL
--> http://www.php.net : NULL
--> http://www.php.net/ : NULL
--> www.php.net:80 : NULL
--> http://www.php.net:80 : NULL
--> http://www.php.net:80/ : NULL
--> http://www.php.net/index.php : NULL
--> www.php.net/? : NULL
--> www.php.net:80/? : NULL
--> http://www.php.net/? : NULL
--> http://www.php.net:80/? : NULL
--> http://www.php.net:80/index.php : NULL
--> http://www.php.net:80/foo/bar/index.php : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2&parameters=3&too=4&here=5 : string(37) "lots=1&of=2&parameters=3&too=4&here=5"
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/ : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : NULL
--> http://www.php.net:80/this/../a/../deep/directory : NULL
--> http://www.php.net:80/this/../a/../deep/directory/ : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php : NULL
--> http://www.php.net:80/index.php : NULL
--> http://www.php.net:80/index.php? : NULL
--> http://www.php.net:80/#foo : NULL
--> http://www.php.net:80/?# : NULL
--> http://www.php.net:80/?test=1 : string(6) "test=1"
--> http://www.php.net/?test=1& : string(7) "test=1&"
--> http://www.php.net:80/?& : string(1) "&"
--> http://www.php.net:80/index.php?test=1& : string(7) "test=1&"
--> http://www.php.net/index.php?& : string(1) "&"
--> http://www.php.net:80/index.php?foo& : string(4) "foo&"
--> http://www.php.net/index.php?&foo : string(4) "&foo"
--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : string(31) "test=1&test2=char&test3=mixesCI"
--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(31) "test=1&test2=char&test3=mixesCI"
--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(31) "test=1&test2=char&test3=mixesCI"
--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(31) "test=1&test2=char&test3=mixesCI"
--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(31) "test=1&test2=char&test3=mixesCI"
--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(31) "test=1&test2=char&test3=mixesCI"
--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(31) "test=1&test2=char&test3=mixesCI"
--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(31) "test=1&test2=char&test3=mixesCI"
--> nntp://news.php.net : NULL
--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz : NULL
--> zlib:http://foo@bar : NULL
--> zlib:filename.txt : NULL
--> zlib:/path/to/my/file/file.txt : NULL
--> foo://foo@bar : NULL
--> mailto:me@mydomain.com : NULL
--> /foo.php?a=b&c=d : string(7) "a=b&c=d"
--> foo.php?a=b&c=d : string(7) "a=b&c=d"
--> http://user:passwd@www.example.com:8080?bar=1&boom=0 : string(12) "bar=1&boom=0"
--> file:///path/to/file : NULL
--> file://path/to/file : NULL
--> file:/path/to/file : NULL
--> http://1.2.3.4:/abc.asp?a=1&b=2 : string(7) "a=1&b=2"
--> http://foo.com#bar : NULL
--> scheme: : NULL
--> foo+bar://baz@bang/bla : NULL
--> gg:9130731 : NULL
--> http://user:@pass@host/path?argument?value#etc : string(14) "argument?value"
--> http://10.10.10.10/:80 : NULL
--> http://x:? : NULL
--> x:blah.com : NULL
--> x:/blah.com : NULL
--> x://::abc/? : NULL
--> http://::? : NULL
--> x://::6.5 : NULL
--> http://?:/ : NULL
--> http://@?:/ : NULL
--> file:///: : NULL
--> file:///a:/ : NULL
--> file:///ab:/ : NULL
--> file:///a:/ : NULL
--> file:///@:/ : NULL
--> file:///:80/ : NULL
--> [] : NULL
--> http://[x:80]/ : NULL
--> : NULL
--> / : NULL
--> http:///blah.com :
Warning: parse_url(http:///blah.com): Unable to parse URL in %s on line 15
bool(false)
--> http://:80 :
Warning: parse_url(http://:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user@:80 :
Warning: parse_url(http://user@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user:pass@:80 :
Warning: parse_url(http://user:pass@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://: :
Warning: parse_url(http://:): Unable to parse URL in %s on line 15
bool(false)
--> http://@/ :
Warning: parse_url(http://@/): Unable to parse URL in %s on line 15
bool(false)
--> http://@:/ :
Warning: parse_url(http://@:/): Unable to parse URL in %s on line 15
bool(false)
--> http://:/ :
Warning: parse_url(http://:/): Unable to parse URL in %s on line 15
bool(false)
--> http://? :
Warning: parse_url(http://?): Unable to parse URL in %s on line 15
bool(false)
--> http://?: :
Warning: parse_url(http://?:): Unable to parse URL in %s on line 15
bool(false)
--> http://:? :
Warning: parse_url(http://:?): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:123456 :
Warning: parse_url(http://blah.com:123456): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:abcdef :
Warning: parse_url(http://blah.com:abcdef): Unable to parse URL in %s on line 15
bool(false)
Done

View file

@ -0,0 +1,150 @@
--TEST--
Test parse_url() function: Parse a load of URLs without specifying PHP_URL_FRAGMENT as the URL component
--FILE--
<?php
/* Prototype : proto mixed parse_url(string url, [int url_component])
* Description: Parse a URL and return its components
* Source code: ext/standard/url.c
* Alias to functions:
*/
/*
* Parse a load of URLs without specifying PHP_URL_FRAGMENT as the URL component
*/
include_once(dirname(__FILE__) . '/urls.inc');
foreach ($urls as $url) {
echo "--> $url : ";
var_dump(parse_url($url, PHP_URL_FRAGMENT));
}
echo "Done";
?>
--EXPECTF--
--> 64.246.30.37 : NULL
--> http://64.246.30.37 : NULL
--> http://64.246.30.37/ : NULL
--> 64.246.30.37/ : NULL
--> 64.246.30.37:80/ : NULL
--> php.net : NULL
--> php.net/ : NULL
--> http://php.net : NULL
--> http://php.net/ : NULL
--> www.php.net : NULL
--> www.php.net/ : NULL
--> http://www.php.net : NULL
--> http://www.php.net/ : NULL
--> www.php.net:80 : NULL
--> http://www.php.net:80 : NULL
--> http://www.php.net:80/ : NULL
--> http://www.php.net/index.php : NULL
--> www.php.net/? : NULL
--> www.php.net:80/? : NULL
--> http://www.php.net/? : NULL
--> http://www.php.net:80/? : NULL
--> http://www.php.net:80/index.php : NULL
--> http://www.php.net:80/foo/bar/index.php : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2&parameters=3&too=4&here=5 : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/ : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : NULL
--> http://www.php.net:80/this/../a/../deep/directory : NULL
--> http://www.php.net:80/this/../a/../deep/directory/ : NULL
--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php : NULL
--> http://www.php.net:80/index.php : NULL
--> http://www.php.net:80/index.php? : NULL
--> http://www.php.net:80/#foo : string(3) "foo"
--> http://www.php.net:80/?# : NULL
--> http://www.php.net:80/?test=1 : NULL
--> http://www.php.net/?test=1& : NULL
--> http://www.php.net:80/?& : NULL
--> http://www.php.net:80/index.php?test=1& : NULL
--> http://www.php.net/index.php?& : NULL
--> http://www.php.net:80/index.php?foo& : NULL
--> http://www.php.net/index.php?&foo : NULL
--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : NULL
--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(16) "some_page_ref123"
--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(16) "some_page_ref123"
--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(16) "some_page_ref123"
--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(16) "some_page_ref123"
--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(16) "some_page_ref123"
--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(16) "some_page_ref123"
--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(16) "some_page_ref123"
--> nntp://news.php.net : NULL
--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz : NULL
--> zlib:http://foo@bar : NULL
--> zlib:filename.txt : NULL
--> zlib:/path/to/my/file/file.txt : NULL
--> foo://foo@bar : NULL
--> mailto:me@mydomain.com : NULL
--> /foo.php?a=b&c=d : NULL
--> foo.php?a=b&c=d : NULL
--> http://user:passwd@www.example.com:8080?bar=1&boom=0 : NULL
--> file:///path/to/file : NULL
--> file://path/to/file : NULL
--> file:/path/to/file : NULL
--> http://1.2.3.4:/abc.asp?a=1&b=2 : NULL
--> http://foo.com#bar : string(3) "bar"
--> scheme: : NULL
--> foo+bar://baz@bang/bla : NULL
--> gg:9130731 : NULL
--> http://user:@pass@host/path?argument?value#etc : string(3) "etc"
--> http://10.10.10.10/:80 : NULL
--> http://x:? : NULL
--> x:blah.com : NULL
--> x:/blah.com : NULL
--> x://::abc/? : NULL
--> http://::? : NULL
--> x://::6.5 : NULL
--> http://?:/ : NULL
--> http://@?:/ : NULL
--> file:///: : NULL
--> file:///a:/ : NULL
--> file:///ab:/ : NULL
--> file:///a:/ : NULL
--> file:///@:/ : NULL
--> file:///:80/ : NULL
--> [] : NULL
--> http://[x:80]/ : NULL
--> : NULL
--> / : NULL
--> http:///blah.com :
Warning: parse_url(http:///blah.com): Unable to parse URL in %s on line 15
bool(false)
--> http://:80 :
Warning: parse_url(http://:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user@:80 :
Warning: parse_url(http://user@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://user:pass@:80 :
Warning: parse_url(http://user:pass@:80): Unable to parse URL in %s on line 15
bool(false)
--> http://: :
Warning: parse_url(http://:): Unable to parse URL in %s on line 15
bool(false)
--> http://@/ :
Warning: parse_url(http://@/): Unable to parse URL in %s on line 15
bool(false)
--> http://@:/ :
Warning: parse_url(http://@:/): Unable to parse URL in %s on line 15
bool(false)
--> http://:/ :
Warning: parse_url(http://:/): Unable to parse URL in %s on line 15
bool(false)
--> http://? :
Warning: parse_url(http://?): Unable to parse URL in %s on line 15
bool(false)
--> http://?: :
Warning: parse_url(http://?:): Unable to parse URL in %s on line 15
bool(false)
--> http://:? :
Warning: parse_url(http://:?): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:123456 :
Warning: parse_url(http://blah.com:123456): Unable to parse URL in %s on line 15
bool(false)
--> http://blah.com:abcdef :
Warning: parse_url(http://blah.com:abcdef): Unable to parse URL in %s on line 15
bool(false)
Done

View file

@ -0,0 +1,31 @@
--TEST--
Test parse_url() function : check values of URL related constants
--FILE--
<?php
/* Prototype : proto mixed parse_url(string url, [int url_component])
* Description: Parse a URL and return its components
* Source code: ext/standard/url.c
* Alias to functions:
*/
/*
* check values of URL related constants
*/
foreach(get_defined_constants() as $constantName => $constantValue) {
if (strpos($constantName, 'PHP_URL')===0) {
echo "$constantName: $constantValue \n";
}
}
echo "Done";
?>
--EXPECTF--
PHP_URL_SCHEME: 0
PHP_URL_HOST: 1
PHP_URL_PORT: 2
PHP_URL_USER: 3
PHP_URL_PASS: 4
PHP_URL_PATH: 5
PHP_URL_QUERY: 6
PHP_URL_FRAGMENT: 7
Done

View file

@ -0,0 +1,38 @@
--TEST--
Test parse_url() function : error conditions - wrong number of args
--FILE--
<?php
/* Prototype : proto mixed parse_url(string url, [int url_component])
* Description: Parse a URL and return its components
* Source code: ext/standard/url.c
* Alias to functions:
*/
echo "*** Testing parse_url() : error conditions ***\n";
// Zero arguments
echo "\n-- Testing parse_url() function with Zero arguments --\n";
var_dump( parse_url() );
//Test parse_url with one more than the expected number of arguments
echo "\n-- Testing parse_url() function with more than expected no. of arguments --\n";
$url = 'string_val';
$url_component = 10;
$extra_arg = 10;
var_dump( parse_url($url, $url_component, $extra_arg) );
echo "Done";
?>
--EXPECTF--
*** Testing parse_url() : error conditions ***
-- Testing parse_url() function with Zero arguments --
Warning: parse_url() expects at least 1 parameter, 0 given in %s on line 12
NULL
-- Testing parse_url() function with more than expected no. of arguments --
Warning: parse_url() expects at most 2 parameters, 3 given in %s on line 19
NULL
Done

View file

@ -0,0 +1,47 @@
--TEST--
Test parse_url() function: url component specifier out of range
--FILE--
<?php
/* Prototype : proto mixed parse_url(string url, [int url_component])
* Description: Parse a URL and return its components
* Source code: ext/standard/url.c
* Alias to functions:
*/
echo "*** Testing parse_url() : error conditions: url component specifier out of range ***\n";
$url = 'http://secret:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123';
echo "--> Below range:";
var_dump(parse_url($url, -1));
echo "\n\n--> Above range:";
var_dump(parse_url($url, 99));
echo "Done"
?>
--EXPECTF--
*** Testing parse_url() : error conditions: url component specifier out of range ***
--> Below range:array(8) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["user"]=>
string(6) "secret"
["pass"]=>
string(7) "hideout"
["path"]=>
string(10) "/index.php"
["query"]=>
string(31) "test=1&test2=char&test3=mixesCI"
["fragment"]=>
string(16) "some_page_ref123"
}
--> Above range:
Warning: parse_url(): Invalid URL component identifier 99 in %s on line 15
bool(false)
Done

View file

@ -0,0 +1,221 @@
--TEST--
Test parse_url() function : usage variations - <type here specifics of this variation>
--FILE--
<?php
/* Prototype : proto mixed parse_url(string url, [int url_component])
* Description: Parse a URL and return its components
* Source code: ext/standard/url.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 parse_url() : usage variations ***\n";
//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 url
foreach($values as $value) {
echo "\nArg value $value \n";
var_dump( parse_url($value) );
};
echo "Done";
?>
--EXPECTF--
*** Testing parse_url() : usage variations ***
Error: 8 - Undefined variable: undefined_var, %s(60)
Error: 8 - Undefined variable: unset_var, %s(63)
Arg value 0
array(1) {
["path"]=>
string(1) "0"
}
Arg value 1
array(1) {
["path"]=>
string(1) "1"
}
Arg value 12345
array(1) {
["path"]=>
string(5) "12345"
}
Arg value -2345
array(1) {
["path"]=>
string(5) "-2345"
}
Arg value 10.5
array(1) {
["path"]=>
string(4) "10.5"
}
Arg value -10.5
array(1) {
["path"]=>
string(5) "-10.5"
}
Arg value 101234567000
array(1) {
["path"]=>
string(12) "101234567000"
}
Arg value 1.07654321E-9
array(1) {
["path"]=>
string(13) "1.07654321E-9"
}
Arg value 0.5
array(1) {
["path"]=>
string(3) "0.5"
}
Arg value Array
Error: 2 - parse_url() expects parameter 1 to be string, array given, %s(70)
NULL
Arg value Array
Error: 2 - parse_url() expects parameter 1 to be string, array given, %s(70)
NULL
Arg value Array
Error: 2 - parse_url() expects parameter 1 to be string, array given, %s(70)
NULL
Arg value Array
Error: 2 - parse_url() expects parameter 1 to be string, array given, %s(70)
NULL
Arg value Array
Error: 2 - parse_url() expects parameter 1 to be string, array given, %s(70)
NULL
Arg value
array(1) {
["path"]=>
string(0) ""
}
Arg value
array(1) {
["path"]=>
string(0) ""
}
Arg value 1
array(1) {
["path"]=>
string(1) "1"
}
Arg value
array(1) {
["path"]=>
string(0) ""
}
Arg value 1
array(1) {
["path"]=>
string(1) "1"
}
Arg value
array(1) {
["path"]=>
string(0) ""
}
Arg value
array(1) {
["path"]=>
string(0) ""
}
Arg value
array(1) {
["path"]=>
string(0) ""
}
Error: 4096 - Object of class stdClass could not be converted to string, %s(69)
Arg value
Error: 2 - parse_url() expects parameter 1 to be string, object given, %s(70)
NULL
Arg value
array(1) {
["path"]=>
string(0) ""
}
Arg value
array(1) {
["path"]=>
string(0) ""
}
Done

View file

@ -0,0 +1,182 @@
--TEST--
Test parse_url() function : usage variations - <type here specifics of this variation>
--FILE--
<?php
/* Prototype : proto mixed parse_url(string url, [int url_component])
* Description: Parse a URL and return its components
* Source code: ext/standard/url.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 parse_url() : usage variations ***\n";
// Initialise function arguments not being substituted (if any)
$url = 'http://secret:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123';
//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 url_component
foreach($values as $value) {
echo "\nArg value $value \n";
var_dump( parse_url($url, $value) );
};
echo "Done";
?>
--EXPECTF--
*** Testing parse_url() : usage variations ***
Error: 8 - Undefined variable: undefined_var, %s(61)
Error: 8 - Undefined variable: unset_var, %s(64)
Arg value 10.5
Error: 2 - parse_url(): Invalid URL component identifier 10, %s(71)
bool(false)
Arg value -10.5
array(8) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["user"]=>
string(6) "secret"
["pass"]=>
string(7) "hideout"
["path"]=>
string(10) "/index.php"
["query"]=>
string(31) "test=1&test2=char&test3=mixesCI"
["fragment"]=>
string(16) "some_page_ref123"
}
Arg value 101234567000
Error: 2 - parse_url(): Invalid URL component identifier 2147483647, %s(71)
bool(false)
Arg value 1.07654321E-9
string(4) "http"
Arg value 0.5
string(4) "http"
Arg value Array
Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71)
NULL
Arg value Array
Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71)
NULL
Arg value Array
Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71)
NULL
Arg value Array
Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71)
NULL
Arg value Array
Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71)
NULL
Arg value
string(4) "http"
Arg value
string(4) "http"
Arg value 1
string(11) "www.php.net"
Arg value
string(4) "http"
Arg value 1
string(11) "www.php.net"
Arg value
string(4) "http"
Arg value
Error: 2 - parse_url() expects parameter 2 to be long, string given, %s(71)
NULL
Arg value
Error: 2 - parse_url() expects parameter 2 to be long, string given, %s(71)
NULL
Arg value string
Error: 2 - parse_url() expects parameter 2 to be long, string given, %s(71)
NULL
Arg value string
Error: 2 - parse_url() expects parameter 2 to be long, string given, %s(71)
NULL
Error: 4096 - Object of class stdClass could not be converted to string, %s(70)
Arg value
Error: 2 - parse_url() expects parameter 2 to be long, object given, %s(71)
NULL
Arg value
string(4) "http"
Arg value
string(4) "http"
Done

View file

@ -0,0 +1,39 @@
--TEST--
Test rawurldecode() function : error conditions - wrong number of args
--FILE--
<?php
/* Prototype : proto string rawurldecode(string str)
* Description: Decodes URL-encodes string
* Source code: ext/standard/url.c
* Alias to functions:
*/
// NB: basic functionality tested in tests/strings/001.phpt
echo "*** Testing rawurldecode() : error conditions ***\n";
// Zero arguments
echo "\n-- Testing rawurldecode() function with Zero arguments --\n";
var_dump( rawurldecode() );
//Test rawurldecode with one more than the expected number of arguments
echo "\n-- Testing rawurldecode() function with more than expected no. of arguments --\n";
$str = 'string_val';
$extra_arg = 10;
var_dump( rawurldecode($str, $extra_arg) );
echo "Done";
?>
--EXPECTF--
*** Testing rawurldecode() : error conditions ***
-- Testing rawurldecode() function with Zero arguments --
Warning: rawurldecode() expects exactly 1 parameter, 0 given in %s on line 14
NULL
-- Testing rawurldecode() function with more than expected no. of arguments --
Warning: rawurldecode() expects exactly 1 parameter, 2 given in %s on line 20
NULL
Done

View file

@ -0,0 +1,168 @@
--TEST--
Test rawurldecode() function : usage variations - unexpected type for arg 1.
--FILE--
<?php
/* Prototype : proto string rawurldecode(string str)
* Description: Decodes URL-encodes string
* Source code: ext/standard/url.c
* Alias to functions:
*/
// NB: basic functionality tested in tests/strings/001.phpt
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 rawurldecode() : 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 str
foreach($values as $value) {
echo "\nArg value $value \n";
var_dump( rawurldecode($value) );
};
echo "Done";
?>
--EXPECTF--
*** Testing rawurldecode() : 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(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(13) "1.07654321E-9"
Arg value 0.5
string(3) "0.5"
Arg value Array
Error: 2 - rawurldecode() expects parameter 1 to be string, array given, %s(74)
NULL
Arg value Array
Error: 2 - rawurldecode() expects parameter 1 to be string, array given, %s(74)
NULL
Arg value Array
Error: 2 - rawurldecode() expects parameter 1 to be string, array given, %s(74)
NULL
Arg value Array
Error: 2 - rawurldecode() expects parameter 1 to be string, array given, %s(74)
NULL
Arg value Array
Error: 2 - rawurldecode() expects parameter 1 to be string, array given, %s(74)
NULL
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(73)
Arg value
Error: 2 - rawurldecode() expects parameter 1 to be string, object given, %s(74)
NULL
Arg value
string(0) ""
Arg value
string(0) ""
Done

View file

@ -0,0 +1,39 @@
--TEST--
Test rawurlencode() function : error conditions
--FILE--
<?php
/* Prototype : proto string rawurlencode(string str)
* Description: URL-encodes string
* Source code: ext/standard/url.c
* Alias to functions:
*/
// NB: basic functionality tested in tests/strings/001.phpt
echo "*** Testing rawurlencode() : error conditions ***\n";
// Zero arguments
echo "\n-- Testing rawurlencode() function with Zero arguments --\n";
var_dump( rawurlencode() );
//Test rawurlencode with one more than the expected number of arguments
echo "\n-- Testing rawurlencode() function with more than expected no. of arguments --\n";
$str = 'string_val';
$extra_arg = 10;
var_dump( rawurlencode($str, $extra_arg) );
echo "Done";
?>
--EXPECTF--
*** Testing rawurlencode() : error conditions ***
-- Testing rawurlencode() function with Zero arguments --
Warning: rawurlencode() expects exactly 1 parameter, 0 given in %s on line 14
NULL
-- Testing rawurlencode() function with more than expected no. of arguments --
Warning: rawurlencode() expects exactly 1 parameter, 2 given in %s on line 20
NULL
Done

View file

@ -0,0 +1,168 @@
--TEST--
Test rawurlencode() function : usage variations - unexpected type for arg 1.
--FILE--
<?php
/* Prototype : proto string rawurlencode(string str)
* Description: URL-encodes string
* Source code: ext/standard/url.c
* Alias to functions:
*/
// NB: basic functionality tested in tests/strings/001.phpt
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 rawurlencode() : 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 str
foreach($values as $value) {
echo "\nArg value $value \n";
var_dump( rawurlencode($value) );
};
echo "Done";
?>
--EXPECTF--
*** Testing rawurlencode() : 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(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(13) "1.07654321E-9"
Arg value 0.5
string(3) "0.5"
Arg value Array
Error: 2 - rawurlencode() expects parameter 1 to be string, array given, %s(74)
NULL
Arg value Array
Error: 2 - rawurlencode() expects parameter 1 to be string, array given, %s(74)
NULL
Arg value Array
Error: 2 - rawurlencode() expects parameter 1 to be string, array given, %s(74)
NULL
Arg value Array
Error: 2 - rawurlencode() expects parameter 1 to be string, array given, %s(74)
NULL
Arg value Array
Error: 2 - rawurlencode() expects parameter 1 to be string, array given, %s(74)
NULL
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(73)
Arg value
Error: 2 - rawurlencode() expects parameter 1 to be string, object given, %s(74)
NULL
Arg value
string(0) ""
Arg value
string(0) ""
Done

View file

@ -0,0 +1,39 @@
--TEST--
Test urldecode() function : error conditions
--FILE--
<?php
/* Prototype : proto string urldecode(string str)
* Description: Decodes URL-encoded string
* Source code: ext/standard/url.c
* Alias to functions:
*/
// NB: basic functionality tested in tests/strings/001.phpt
echo "*** Testing urldecode() : error conditions ***\n";
// Zero arguments
echo "\n-- Testing urldecode() function with Zero arguments --\n";
var_dump( urldecode() );
//Test urldecode with one more than the expected number of arguments
echo "\n-- Testing urldecode() function with more than expected no. of arguments --\n";
$str = 'string_val';
$extra_arg = 10;
var_dump( urldecode($str, $extra_arg) );
echo "Done";
?>
--EXPECTF--
*** Testing urldecode() : error conditions ***
-- Testing urldecode() function with Zero arguments --
Warning: urldecode() expects exactly 1 parameter, 0 given in %s on line 14
NULL
-- Testing urldecode() function with more than expected no. of arguments --
Warning: urldecode() expects exactly 1 parameter, 2 given in %s on line 20
NULL
Done

View file

@ -0,0 +1,168 @@
--TEST--
Test urldecode() function : usage variations - <type here specifics of this variation>
--FILE--
<?php
/* Prototype : proto string urldecode(string str)
* Description: Decodes URL-encoded string
* Source code: ext/standard/url.c
* Alias to functions:
*/
// NB: basic functionality tested in tests/strings/001.phpt
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 urldecode() : 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 str
foreach($values as $value) {
echo "\nArg value $value \n";
var_dump( urldecode($value) );
};
echo "Done";
?>
--EXPECTF--
*** Testing urldecode() : 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(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(13) "1.07654321E-9"
Arg value 0.5
string(3) "0.5"
Arg value Array
Error: 2 - urldecode() expects parameter 1 to be string, array given, %s(74)
NULL
Arg value Array
Error: 2 - urldecode() expects parameter 1 to be string, array given, %s(74)
NULL
Arg value Array
Error: 2 - urldecode() expects parameter 1 to be string, array given, %s(74)
NULL
Arg value Array
Error: 2 - urldecode() expects parameter 1 to be string, array given, %s(74)
NULL
Arg value Array
Error: 2 - urldecode() expects parameter 1 to be string, array given, %s(74)
NULL
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(73)
Arg value
Error: 2 - urldecode() expects parameter 1 to be string, object given, %s(74)
NULL
Arg value
string(0) ""
Arg value
string(0) ""
Done

View file

@ -0,0 +1,39 @@
--TEST--
Test urlencode() function : error conditions
--FILE--
<?php
/* Prototype : proto string urlencode(string str)
* Description: URL-encodes string
* Source code: ext/standard/url.c
* Alias to functions:
*/
// NB: basic functionality tested in tests/strings/001.phpt
echo "*** Testing urlencode() : error conditions ***\n";
// Zero arguments
echo "\n-- Testing urlencode() function with Zero arguments --\n";
var_dump( urlencode() );
//Test urlencode with one more than the expected number of arguments
echo "\n-- Testing urlencode() function with more than expected no. of arguments --\n";
$str = 'string_val';
$extra_arg = 10;
var_dump( urlencode($str, $extra_arg) );
echo "Done";
?>
--EXPECTF--
*** Testing urlencode() : error conditions ***
-- Testing urlencode() function with Zero arguments --
Warning: urlencode() expects exactly 1 parameter, 0 given in %s on line 14
NULL
-- Testing urlencode() function with more than expected no. of arguments --
Warning: urlencode() expects exactly 1 parameter, 2 given in %s on line 20
NULL
Done

View file

@ -0,0 +1,168 @@
--TEST--
Test urlencode() function : usage variations - <type here specifics of this variation>
--FILE--
<?php
/* Prototype : proto string urlencode(string str)
* Description: URL-encodes string
* Source code: ext/standard/url.c
* Alias to functions:
*/
// NB: basic functionality tested in tests/strings/001.phpt
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 urlencode() : 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 str
foreach($values as $value) {
echo "\nArg value $value \n";
var_dump( urlencode($value) );
};
echo "Done";
?>
--EXPECTF--
*** Testing urlencode() : 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(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(13) "1.07654321E-9"
Arg value 0.5
string(3) "0.5"
Arg value Array
Error: 2 - urlencode() expects parameter 1 to be string, array given, %s(74)
NULL
Arg value Array
Error: 2 - urlencode() expects parameter 1 to be string, array given, %s(74)
NULL
Arg value Array
Error: 2 - urlencode() expects parameter 1 to be string, array given, %s(74)
NULL
Arg value Array
Error: 2 - urlencode() expects parameter 1 to be string, array given, %s(74)
NULL
Arg value Array
Error: 2 - urlencode() expects parameter 1 to be string, array given, %s(74)
NULL
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(73)
Arg value
Error: 2 - urlencode() expects parameter 1 to be string, object given, %s(74)
NULL
Arg value
string(0) ""
Arg value
string(0) ""
Done

View file

@ -0,0 +1,109 @@
<?php
$urls = array(
// Parsable URLs:
'64.246.30.37',
'http://64.246.30.37',
'http://64.246.30.37/',
'64.246.30.37/',
'64.246.30.37:80/',
'php.net',
'php.net/',
'http://php.net',
'http://php.net/',
'www.php.net',
'www.php.net/',
'http://www.php.net',
'http://www.php.net/',
'www.php.net:80',
'http://www.php.net:80',
'http://www.php.net:80/',
'http://www.php.net/index.php',
'www.php.net/?',
'www.php.net:80/?',
'http://www.php.net/?',
'http://www.php.net:80/?',
'http://www.php.net:80/index.php',
'http://www.php.net:80/foo/bar/index.php',
'http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php',
'http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2&parameters=3&too=4&here=5',
'http://www.php.net:80/this/is/a/very/deep/directory/structure/and/',
'http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php',
'http://www.php.net:80/this/../a/../deep/directory',
'http://www.php.net:80/this/../a/../deep/directory/',
'http://www.php.net:80/this/is/a/very/deep/directory/../file.php',
'http://www.php.net:80/index.php',
'http://www.php.net:80/index.php?',
'http://www.php.net:80/#foo',
'http://www.php.net:80/?#',
'http://www.php.net:80/?test=1',
'http://www.php.net/?test=1&',
'http://www.php.net:80/?&',
'http://www.php.net:80/index.php?test=1&',
'http://www.php.net/index.php?&',
'http://www.php.net:80/index.php?foo&',
'http://www.php.net/index.php?&foo',
'http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI',
'www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123',
'http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123',
'http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123',
'http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123',
'http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123',
'http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123',
'http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123',
'nntp://news.php.net',
'ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz',
'zlib:http://foo@bar',
'zlib:filename.txt',
'zlib:/path/to/my/file/file.txt',
'foo://foo@bar',
'mailto:me@mydomain.com',
'/foo.php?a=b&c=d',
'foo.php?a=b&c=d',
'http://user:passwd@www.example.com:8080?bar=1&boom=0',
'file:///path/to/file',
'file://path/to/file',
'file:/path/to/file',
'http://1.2.3.4:/abc.asp?a=1&b=2',
'http://foo.com#bar',
'scheme:',
'foo+bar://baz@bang/bla',
'gg:9130731',
'http://user:@pass@host/path?argument?value#etc',
'http://10.10.10.10/:80',
'http://x:?',
'x:blah.com',
'x:/blah.com',
'x://::abc/?',
'http://::?',
'x://::6.5',
'http://?:/',
'http://@?:/',
'file:///:',
'file:///a:/',
'file:///ab:/',
'file:///a:/',
'file:///@:/',
'file:///:80/',
'[]',
'http://[x:80]/',
'',
'/',
// Severely malformed URLs that do not parse:
'http:///blah.com',
'http://:80',
'http://user@:80',
'http://user:pass@:80',
'http://:',
'http://@/',
'http://@:/',
'http://:/',
'http://?',
'http://?:',
'http://:?',
'http://blah.com:123456',
'http://blah.com:abcdef',
);
?>