cvs: pear /PHP_Compat/tests loadconstant.phpt loadfunction.phpt /PHP_Compat/tests/constant e_strict.phpt file.phpt path_separator.phpt std.phpt
/PHP_Compat/tests/function array_change_key_case.phpt array_chunk.phpt array_combine.phpt array_diff_assoc.phpt array_udif_assoc.phpt array_udiff.phpt
file_get_contents.phpt file_put_contents.phpt fprintf.phpt html_entity_decode.phpt http_build_query.phpt is_a.phpt scandir.phpt str_ireplace.phpt
str_split.phpt stripos.phpt strripos.phpt var_export.phpt vprintf.phpt vsprintf.phpt
| From: | Aidan Lister | Date: | Sun, 13 Jun 2004 17:21:11 +0000 |
| Subject: | cvs: pear /PHP_Compat/tests loadconstant.phpt loadfunction.phpt /PHP_Compat/tests/constant e_strict.phpt file.phpt path_separator.phpt std.phpt /PHP_Compat/tests/function array_change_key_case.phpt array_chunk.phpt array_combine.phpt array_diff_assoc.phpt array_udif_assoc.phpt array_udiff.phpt file_get_contents.phpt file_put_contents.phpt fprintf.phpt html_entity_decode.phpt http_build_query.phpt is_a.phpt scandir.phpt str_ireplace.phpt str_split.phpt stripos.phpt strripos.phpt var_export.phpt vprintf.phpt vsprintf.phpt |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-20604@lists.php.net to get a copy of this message | ||
aidan Sun Jun 13 13:21:11 2004 EDT
Added files:
/pear/PHP_Compat/tests/constant e_strict.phpt file.phpt
path_separator.phpt std.phpt
/pear/PHP_Compat/tests/function array_change_key_case.phpt
array_chunk.phpt array_combine.phpt
array_diff_assoc.phpt
array_udif_assoc.phpt
array_udiff.phpt
file_get_contents.phpt
file_put_contents.phpt fprintf.phpt
html_entity_decode.phpt
http_build_query.phpt is_a.phpt
scandir.phpt str_ireplace.phpt
str_split.phpt stripos.phpt
strripos.phpt var_export.phpt
vprintf.phpt vsprintf.phpt
/pear/PHP_Compat/tests loadconstant.phpt loadfunction.phpt
Log:
Renamed
http://cvs.php.net/co.php/pear/PHP_Compat/tests/constant/e_strict.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/constant/e_strict.phpt +++ pear/PHP_Compat/tests/constant/e_strict.phpt --TEST-- Constant -- E_STRICT --SKIPIF-- <?php if (defined('E_STRICT')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadConstant('E_STRICT'); echo E_STRICT; ?> --EXPECT-- 2048 http://cvs.php.net/co.php/pear/PHP_Compat/tests/constant/file.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/constant/file.phpt +++ pear/PHP_Compat/tests/constant/file.phpt --TEST-- Constant -- File System Constants --SKIPIF-- <?php if (defined('FILE_USE_INCLUDE_PATH')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadConstant('FILE'); echo FILE_USE_INCLUDE_PATH, "\n"; echo FILE_IGNORE_NEW_LINES, "\n"; echo FILE_SKIP_EMPTY_LINES, "\n"; echo FILE_APPEND, "\n"; echo FILE_NO_DEFAULT_CONTEXT ?> --EXPECT-- 1 2 4 8 16 http://cvs.php.net/co.php/pear/PHP_Compat/tests/constant/path_separator.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/constant/path_separator.phpt +++ pear/PHP_Compat/tests/constant/path_separator.phpt --TEST-- Constant -- PATH_SEPARATOR --SKIPIF-- <?php if (defined('PATH_SEPARATOR')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadConstant('PATH_SEPARATOR'); echo (PATH_SEPARATOR == ';' || PATH_SEPARATOR == ':') ? 'true' : 'false'; ?> --EXPECT-- true http://cvs.php.net/co.php/pear/PHP_Compat/tests/constant/std.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/constant/std.phpt +++ pear/PHP_Compat/tests/constant/std.phpt --TEST-- Constant -- CLI Constants --SKIPIF-- <?php if (defined('STDIN')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadConstant('STD'); echo (is_resource(STDIN)) ? 'true' : 'false', "\n"; echo (is_resource(STDOUT)) ? 'true' : 'false', "\n"; echo (is_resource(STDERR)) ? 'true' : 'false'; ?> --EXPECT-- true true true http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/array_change_key_case.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/array_change_key_case.phpt +++ pear/PHP_Compat/tests/function/array_change_key_case.phpt --TEST-- Function -- array_change_key_case --SKIPIF-- <?php if (function_exists('array_change_key_case')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('array_change_key_case'); // The array $input_array = array("FirSt" => 1, "SecOnd" => 4); // Default to lower print_r(array_change_key_case($input_array)); // Lower print_r(array_change_key_case($input_array, CASE_LOWER)); // Upper print_r(array_change_key_case($input_array, CASE_UPPER)); ?> --EXPECT-- Array ( [first] => 1 [second] => 4 ) Array ( [first] => 1 [second] => 4 ) Array ( [FIRST] => 1 [SECOND] => 4 ) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/array_chunk.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/array_chunk.phpt +++ pear/PHP_Compat/tests/function/array_chunk.phpt --TEST-- Function -- array_chunk --SKIPIF-- <?php if (function_exists('array_chunk')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('array_chunk'); $input_array = array(2 => 'a', 3 => 'b', 4 => 'c', 5 => 'd', 6 => 'e'); print_r(array_chunk($input_array, 2)); print_r(array_chunk($input_array, 2, true)); print_r(array_chunk($input_array, 3)); print_r(array_chunk($input_array, 3, true)); print_r(array_chunk($input_array, 4)); print_r(array_chunk($input_array, 4, true)); print_r(array_chunk($input_array, 5)); print_r(array_chunk($input_array, 5, true)); print_r(array_chunk($input_array, 6)); print_r(array_chunk($input_array, 6, true)); ?> --EXPECT-- Array ( [0] => Array ( [0] => a [1] => b ) [1] => Array ( [0] => c [1] => d ) [2] => Array ( [0] => e ) ) Array ( [0] => Array ( [2] => a [3] => b ) [1] => Array ( [4] => c [5] => d ) [2] => Array ( [6] => e ) ) Array ( [0] => Array ( [0] => a [1] => b [2] => c ) [1] => Array ( [0] => d [1] => e ) ) Array ( [0] => Array ( [2] => a [3] => b [4] => c ) [1] => Array ( [5] => d [6] => e ) ) Array ( [0] => Array ( [0] => a [1] => b [2] => c [3] => d ) [1] => Array ( [0] => e ) ) Array ( [0] => Array ( [2] => a [3] => b [4] => c [5] => d ) [1] => Array ( [6] => e ) ) Array ( [0] => Array ( [0] => a [1] => b [2] => c [3] => d [4] => e ) ) Array ( [0] => Array ( [2] => a [3] => b [4] => c [5] => d [6] => e ) ) Array ( [0] => Array ( [0] => a [1] => b [2] => c [3] => d [4] => e ) ) Array ( [0] => Array ( [2] => a [3] => b [4] => c [5] => d [6] => e ) ) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/array_combine.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/array_combine.phpt +++ pear/PHP_Compat/tests/function/array_combine.phpt --TEST-- Function -- array_combine --SKIPIF-- <?php if (function_exists('array_combine')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('array_combine'); $a = array('green', 'red', 'yellow'); $b = array('avocado', 'apple', 'banana'); $c = array_combine($a, $b); print_r($c); ?> --EXPECT-- Array ( [green] => avocado [red] => apple [yellow] => banana ) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/array_diff_assoc.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/array_diff_assoc.phpt +++ pear/PHP_Compat/tests/function/array_diff_assoc.phpt --TEST-- Function -- array_diff_assoc --SKIPIF-- <?php if (function_exists('array_diff_assoc')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('array_diff_assoc'); $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "green", "yellow", "red"); $result = array_diff_assoc($array1, $array2); print_r($result); ?> --EXPECT-- Array ( [b] => brown [c] => blue [0] => red ) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/array_udif_assoc.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/array_udif_assoc.phpt +++ pear/PHP_Compat/tests/function/array_udif_assoc.phpt --TEST-- Function -- array_udiff_assoc --SKIPIF-- <?php if (function_exists('array_udiff_assoc')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('array_udiff_assoc'); class cr { var $priv_member; function cr($val) { $this->priv_member = $val; } function comp_func_cr($a, $b) { if ($a->priv_member === $b->priv_member) return 0; return ($a->priv_member > $b->priv_member)? 1:-1; } } $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),); $result = array_udiff_assoc($a, $b, array("cr", "comp_func_cr")); echo serialize($result); ?> --EXPECT-- a:3:{s:3:"0.1";O:2:"cr":1:{s:11:"priv_member";i:9;}s:3:"0.5";O:2:"cr":1:{s:11:"priv_member";i:12;}i:0;O:2:"cr":1:{s:11:"priv_member";i:23;}} http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/array_udiff.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/array_udiff.phpt +++ pear/PHP_Compat/tests/function/array_udiff.phpt --TEST-- Function -- array_udiff --SKIPIF-- <?php if (function_exists('array_udiff')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('array_udiff'); class cr { var $priv_member; function cr($val) { $this->priv_member = $val; } function comp_func_cr($a, $b) { if ($a->priv_member === $b->priv_member) return 0; return ($a->priv_member > $b->priv_member)? 1:-1; } } $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),); $result = array_udiff($a, $b, array("cr", "comp_func_cr")); echo serialize($result); ?> --EXPECT-- a:2:{s:3:"0.5";O:2:"cr":1:{s:11:"priv_member";i:12;}i:0;O:2:"cr":1:{s:11:"priv_member";i:23;}} http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/file_get_contents.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/file_get_contents.phpt +++ pear/PHP_Compat/tests/function/file_get_contents.phpt --TEST-- Function -- file_get_contents --SKIPIF-- <?php if (function_exists('file_get_contents')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('file_get_contents'); $tmpfname = tempnam('/tmp', 'php'); $handle = fopen($tmpfname, 'w'); fwrite($handle, "test test"); fclose($handle); echo file_get_contents($tmpfname); unlink($tmpfname); ?> --EXPECT-- test test http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/file_put_contents.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/file_put_contents.phpt +++ pear/PHP_Compat/tests/function/file_put_contents.phpt --TEST-- Function -- file_put_contents --SKIPIF-- <?php if (function_exists('file_put_contents')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('file_put_contents'); // With a string $string = "abcd"; $tmpfname = tempnam('/tmp', 'php'); $res = file_put_contents($tmpfname, $string); $data = implode('', file($tmpfname)); unlink($tmpfname); echo $res, "\n"; echo $data, "\n"; // With an array $string = array('foo', 'bar'); $tmpfname = tempnam('/tmp', 'php'); $res = file_put_contents($tmpfname, $string); $data = implode('', file($tmpfname)); unlink($tmpfname); echo $res, "\n"; echo $data, "n"; // Test append $string = 'foobar'; $string2 = 'testtest'; $tmpfname = tempnam('/tmp', 'php'); echo file_put_contents($tmpfname, $string), "\n"; echo file_put_contents($tmpfname, $string2, FILE_APPEND), "\n"; echo implode('', file($tmpfname)), "\n"; echo file_put_contents($tmpfname, $string2), "\n"; echo implode('', file($tmpfname)); unlink($tmpfname); ?> --EXPECT-- 4 abcd 6 foobar 6 8 foobartesttest 8 testtest http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/fprintf.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/fprintf.phpt +++ pear/PHP_Compat/tests/function/fprintf.phpt --TEST-- Function -- fprintf --SKIPIF-- <?php if (function_exists('fprintf')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('fprintf'); $tmpfname = tempnam('/tmp', 'php'); $handle = fopen($tmpfname, 'w'); fprintf($handle, 'The %s went to the %s for %d days', 'dog', 'park', 2); fclose($handle); $data = implode('', file($tmpfname)); unlink($tmpfname); echo $data; ?> --EXPECT-- The dog went to the park for 2 days http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/html_entity_decode.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/html_entity_decode.phpt +++ pear/PHP_Compat/tests/function/html_entity_decode.phpt --TEST-- Function -- html_entity_decode --SKIPIF-- <?php if (function_exists('html_entity_decode')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('html_entity_decode'); $values = array (2, 'car'); $string = "I'll "walk" the <b>dog</b> now"; echo html_entity_decode($string); ?> --EXPECT-- I'll "walk" the <b>dog</b> now http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/http_build_query.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/http_build_query.phpt +++ pear/PHP_Compat/tests/function/http_build_query.phpt --TEST-- Function -- http_build_query --SKIPIF-- <?php if (function_exists('http_build_query')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('http_build_query'); // Simple $data = array('foo'=>'bar', 'baz'=>'boom', 'cow'=>'milk', 'php'=>'hypertext processor'); echo http_build_query($data), "\n"; // With an object class myClass { var $foo; var $baz; function myClass() { $this->foo = 'bar'; $this->baz = 'boom'; } } $data = new myClass(); echo http_build_query($data), "\n"; // With numerically indexed elements $data = array('foo', 'bar', 'baz', 'boom', 'cow' => 'milk', 'php' =>'hypertext processor'); echo http_build_query($data), "\n"; echo http_build_query($data, 'myvar_'), "\n"; // With a complex array $data = array('user'=>array('name'=>'Bob Smith', 'age'=>47, 'sex'=>'M', 'dob'=>'5/12/1956'), 'pastimes'=>array('golf', 'opera', 'poker', 'rap'), 'children'=>array('bobby'=>array('age'=>12, 'sex'=>'M'), 'sally'=>array('age'=>8, 'sex'=>'F')), 'CEO'); echo http_build_query($data, 'flags_'); ?> --EXPECT-- foo=bar&baz=boom&cow=milk&php=hypertext+processor foo=bar&baz=boom 0=foo&1=bar&2=baz&3=boom&cow=milk&php=hypertext+processor myvar_0=foo&myvar_1=bar&myvar_2=baz&myvar_3=boom&cow=milk&php=hypertext+processor user[name]=Bob+Smith&user[age]=47&user[sex]=M&user[dob]=5%2F12%2F1956&pastimes[0]=golf&pastimes[1]=opera&pastimes[2]=poker&pastimes[3]=rap&children[bobby][age]=12&children[bobby][sex]=M&children[sally][age]=8&children[sally][sex]=F&flags_0=CEO http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/is_a.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/is_a.phpt +++ pear/PHP_Compat/tests/function/is_a.phpt --TEST-- Function -- is_a --SKIPIF-- <?php if (function_exists('is_a')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('is_a'); class WidgetFactory { var $oink = 'moo'; } $wf = new WidgetFactory(); if (is_a($wf, 'WidgetFactory')) { echo 'true'; } ?> --EXPECT-- true http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/scandir.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/scandir.phpt +++ pear/PHP_Compat/tests/function/scandir.phpt --TEST-- Function -- scandir --SKIPIF-- <?php if (function_exists('scandir')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('scandir'); // Create a folder and fill it with files mkdir('tmp'); touch('tmp/test1'); touch('tmp/test2'); // Scan it $dir = 'tmp'; // Not sorted $files = scandir($dir); // Sorted $files2 = scandir($dir, 1); // List the results print_r($files); print_r($files2); // Remove the files unlink('tmp/test1'); unlink('tmp/test2'); rmdir('tmp'); ?> --EXPECT-- Array ( [0] => . [1] => .. [2] => test1 [3] => test2 ) Array ( [0] => test2 [1] => test1 [2] => .. [3] => . ) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/str_ireplace.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/str_ireplace.phpt +++ pear/PHP_Compat/tests/function/str_ireplace.phpt --TEST-- Function -- str_ireplace --SKIPIF-- <?php if (function_exists('str_ireplace')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('str_ireplace'); // // Simple // $search = '{object}'; $replace = 'fence'; $subject = 'The dog jumped over the {object}'; echo str_ireplace($search, $replace, $subject), "\n"; // // With subject as array // // As a full array $search = '{SUBJECT}'; $replace = 'Lady'; $subject = array('A {subject}', 'The {subject}', 'My {subject}'); print_r(str_ireplace($search, $replace, $subject)); // As a single array $search = '{SUBJECT}'; $replace = 'Lady'; $subject = array('The dog jumped over the {object}'); print_r(str_ireplace($search, $replace, $subject)); // // Search as string, replace as array // $search = '{object}'; $replace = array('cat', 'dog', 'tiger'); $subject = 'The dog jumped over the {object}'; // Supress the error, no way of knowing how it'll turn out on the users machine echo @str_ireplace($search, $replace, $subject), "\n"; // // Search as array, Replace as string // $search = array('{ANIMAL}', '{OBJECT}', '{THING}'); $replace = 'frog'; $subject = 'The {animal} jumped over the {object} and the {thing}...'; echo str_ireplace($search, $replace, $subject), "\n"; // // Search and Replace as arrays // // Simple $search = array('{ANIMAL}', '{OBJECT}'); $replace = array('frog', 'gate'); $subject = 'The {animal} jumped over the {object}'; echo str_ireplace($search, $replace, $subject), "\n"; // More in search $search = array('{ANIMAL}', '{OBJECT}', '{THING}'); $replace = array('frog', 'gate'); $subject = 'The {animal} jumped over the {object} and the {thing}...'; echo str_ireplace($search, $replace, $subject), "\n"; // More in replace $search = array('{ANIMAL}', '{OBJECT}'); $replace = array('frog', 'gate', 'door'); $subject = 'The {animal} jumped over the {object} and the {thing}...'; echo str_ireplace($search, $replace, $subject), "\n"; // // All arrays // $search = array('{ANIMAL}', '{OBJECT}', '{THING}'); $replace = array('frog', 'gate', 'beer'); $subject = array('A {animal}', 'The {object}', 'My {thing}'); print_r(str_ireplace($search, $replace, $subject)); ?> --EXPECT-- The dog jumped over the fence Array ( [0] => A Lady [1] => The Lady [2] => My Lady ) Array ( [0] => The dog jumped over the {object} ) The dog jumped over the Array The frog jumped over the frog and the frog... The frog jumped over the gate The frog jumped over the gate and the ... The frog jumped over the gate and the {thing}... Array ( [0] => A frog [1] => The gate [2] => My beer ) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/str_split.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/str_split.phpt +++ pear/PHP_Compat/tests/function/str_split.phpt --TEST-- Function -- str_split --SKIPIF-- <?php if (function_exists('str_split')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('str_split'); // Simple $str = "Hello Friend"; $arr = str_split($str); print_r($arr); // With a chunk size specified $str = "Hello Friend"; $arr = str_split($str, 3); print_r($arr); // With chunk size bigger than the string $str = "abcd"; $arr = str_split($str, 3); print_r($arr); // String that has a remainder less than the chunk size $str = "abcd"; $arr = str_split($str, 3); print_r($arr); ?> --EXPECT-- Array ( [0] => H [1] => e [2] => l [3] => l [4] => o [5] => [6] => F [7] => r [8] => i [9] => e [10] => n [11] => d ) Array ( [0] => Hel [1] => lo [2] => Fri [3] => end ) Array ( [0] => abc [1] => d ) Array ( [0] => abc [1] => d ) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/stripos.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/stripos.phpt +++ pear/PHP_Compat/tests/function/stripos.phpt --TEST-- Function -- stripos --SKIPIF-- <?php if (function_exists('stripos')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('stripos'); $haystack = 'Cat Dinner Dog Lion Mouse Sheep Wolf Cat Dog'; $needle = 'DOG'; // Simple var_dump(stripos($haystack, $needle)); // With offset var_dump(stripos($haystack, $needle, 4)); var_dump(stripos($haystack, $needle, 10)); var_dump(stripos($haystack, $needle, 15)); ?> --EXPECT-- int(11) int(11) int(11) int(41) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/strripos.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/strripos.phpt +++ pear/PHP_Compat/tests/function/strripos.phpt --TEST-- Function -- strripos --SKIPIF-- <?php if (function_exists('strripos')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('strripos'); // Simple $haystack = 'Cat Dog Lion Mouse Sheep Wolf Cat Dog'; $needle = 'DOG'; var_dump(strripos($haystack, $needle)); // With offset $haystack = 'Cat Dinner Dog Lion Mouse Sheep Wolf Cat Dog Donut'; $needle = 'DOG'; var_dump(strripos($haystack, $needle, 3)); var_dump(strripos($haystack, $needle, 30)); var_dump(strripos($haystack, $needle, 50)); var_dump(strripos($haystack, $needle, -1)); var_dump(strripos($haystack, $needle, -10)); var_dump(strripos($haystack, $needle, -30)); var_dump(strripos($haystack, $needle, -50)); ?> --EXPECT-- int(34) int(41) int(41) bool(false) int(41) int(11) int(11) bool(false) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/var_export.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/var_export.phpt +++ pear/PHP_Compat/tests/function/var_export.phpt --TEST-- Function -- var_export --SKIPIF-- <?php if (function_exists('var_export')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('var_export'); $a = array (1, 2, array ("a", "b", "c")); var_export($a); echo "\n"; echo var_export($a, true); ?> --EXPECT-- array ( 0 => 1, 1 => 2, 2 => array ( 0 => 'a', 1 => 'b', 2 => 'c', ), ) array ( 0 => 1, 1 => 2, 2 => array ( 0 => 'a', 1 => 'b', 2 => 'c', ), ) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/vprintf.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/vprintf.phpt +++ pear/PHP_Compat/tests/function/vprintf.phpt --TEST-- Function -- vprintf --SKIPIF-- <?php if (function_exists('vprintf')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('vprintf'); $values = array (2, 'car'); $format = "There are %d monkeys in the %s"; vprintf($format, $values); ?> --EXPECT-- There are 2 monkeys in the car http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/vsprintf.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/vsprintf.phpt +++ pear/PHP_Compat/tests/function/vsprintf.phpt --TEST-- Function -- vsprintf --SKIPIF-- <?php if (function_exists('vsprintf')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('vsprintf'); $values = array (2, 'car'); $format = "There are %d monkeys in the %s"; vprintf($format, $values); ?> --EXPECT-- There are 2 monkeys in the car http://cvs.php.net/co.php/pear/PHP_Compat/tests/loadconstant.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/loadconstant.phpt +++ pear/PHP_Compat/tests/loadconstant.phpt --TEST-- Method -- PHP_Compat::loadConstant -- load invalid and valid constants --SKIPIF-- <?php if (defined('E_STRICT')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); // Singular $res = PHP_Compat::loadConstant('invalid'); echo ($res === false) ? 'false' : 'true', "\n"; $res = PHP_Compat::loadConstant('E_STRICT'); echo ($res === false) ? 'false' : 'true'; // With an array $comps = array('invalid', 'also-invalid', 'more-invalid', 'E_STRICT'); $res = PHP_Compat::loadConstant($comps); foreach ($res as $value) { echo ($value === false) ? 'false' : 'true', "\n"; } ?> --EXPECT-- false true false false false true http://cvs.php.net/co.php/pear/PHP_Compat/tests/loadfunction.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/loadfunction.phpt +++ pear/PHP_Compat/tests/loadfunction.phpt --TEST-- Method -- PHP_Compat::loadFunction -- load invalid and valid function --SKIPIF-- <?php if (function_exists('str_split')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); // Singular $res = PHP_Compat::loadFunction('invalid'); echo ($res === false) ? 'false' : 'true', "\n"; $res = PHP_Compat::loadFunction('str_split'); echo ($res === false) ? 'false' : 'true'; // With an array $comps = array('invalid', 'also-invalid', 'more-invalid', 'str_split'); $res = PHP_Compat::loadFunction($comps); foreach ($res as $value) { echo ($value === false) ? 'false' : 'true', "\n"; } ?> --EXPECT-- false true false false false true
http://cvs.php.net/co.php/pear/PHP_Compat/tests/constant/e_strict.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/constant/e_strict.phpt +++ pear/PHP_Compat/tests/constant/e_strict.phpt --TEST-- Constant -- E_STRICT --SKIPIF-- <?php if (defined('E_STRICT')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadConstant('E_STRICT'); echo E_STRICT; ?> --EXPECT-- 2048 http://cvs.php.net/co.php/pear/PHP_Compat/tests/constant/file.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/constant/file.phpt +++ pear/PHP_Compat/tests/constant/file.phpt --TEST-- Constant -- File System Constants --SKIPIF-- <?php if (defined('FILE_USE_INCLUDE_PATH')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadConstant('FILE'); echo FILE_USE_INCLUDE_PATH, "\n"; echo FILE_IGNORE_NEW_LINES, "\n"; echo FILE_SKIP_EMPTY_LINES, "\n"; echo FILE_APPEND, "\n"; echo FILE_NO_DEFAULT_CONTEXT ?> --EXPECT-- 1 2 4 8 16 http://cvs.php.net/co.php/pear/PHP_Compat/tests/constant/path_separator.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/constant/path_separator.phpt +++ pear/PHP_Compat/tests/constant/path_separator.phpt --TEST-- Constant -- PATH_SEPARATOR --SKIPIF-- <?php if (defined('PATH_SEPARATOR')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadConstant('PATH_SEPARATOR'); echo (PATH_SEPARATOR == ';' || PATH_SEPARATOR == ':') ? 'true' : 'false'; ?> --EXPECT-- true http://cvs.php.net/co.php/pear/PHP_Compat/tests/constant/std.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/constant/std.phpt +++ pear/PHP_Compat/tests/constant/std.phpt --TEST-- Constant -- CLI Constants --SKIPIF-- <?php if (defined('STDIN')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadConstant('STD'); echo (is_resource(STDIN)) ? 'true' : 'false', "\n"; echo (is_resource(STDOUT)) ? 'true' : 'false', "\n"; echo (is_resource(STDERR)) ? 'true' : 'false'; ?> --EXPECT-- true true true http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/array_change_key_case.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/array_change_key_case.phpt +++ pear/PHP_Compat/tests/function/array_change_key_case.phpt --TEST-- Function -- array_change_key_case --SKIPIF-- <?php if (function_exists('array_change_key_case')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('array_change_key_case'); // The array $input_array = array("FirSt" => 1, "SecOnd" => 4); // Default to lower print_r(array_change_key_case($input_array)); // Lower print_r(array_change_key_case($input_array, CASE_LOWER)); // Upper print_r(array_change_key_case($input_array, CASE_UPPER)); ?> --EXPECT-- Array ( [first] => 1 [second] => 4 ) Array ( [first] => 1 [second] => 4 ) Array ( [FIRST] => 1 [SECOND] => 4 ) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/array_chunk.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/array_chunk.phpt +++ pear/PHP_Compat/tests/function/array_chunk.phpt --TEST-- Function -- array_chunk --SKIPIF-- <?php if (function_exists('array_chunk')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('array_chunk'); $input_array = array(2 => 'a', 3 => 'b', 4 => 'c', 5 => 'd', 6 => 'e'); print_r(array_chunk($input_array, 2)); print_r(array_chunk($input_array, 2, true)); print_r(array_chunk($input_array, 3)); print_r(array_chunk($input_array, 3, true)); print_r(array_chunk($input_array, 4)); print_r(array_chunk($input_array, 4, true)); print_r(array_chunk($input_array, 5)); print_r(array_chunk($input_array, 5, true)); print_r(array_chunk($input_array, 6)); print_r(array_chunk($input_array, 6, true)); ?> --EXPECT-- Array ( [0] => Array ( [0] => a [1] => b ) [1] => Array ( [0] => c [1] => d ) [2] => Array ( [0] => e ) ) Array ( [0] => Array ( [2] => a [3] => b ) [1] => Array ( [4] => c [5] => d ) [2] => Array ( [6] => e ) ) Array ( [0] => Array ( [0] => a [1] => b [2] => c ) [1] => Array ( [0] => d [1] => e ) ) Array ( [0] => Array ( [2] => a [3] => b [4] => c ) [1] => Array ( [5] => d [6] => e ) ) Array ( [0] => Array ( [0] => a [1] => b [2] => c [3] => d ) [1] => Array ( [0] => e ) ) Array ( [0] => Array ( [2] => a [3] => b [4] => c [5] => d ) [1] => Array ( [6] => e ) ) Array ( [0] => Array ( [0] => a [1] => b [2] => c [3] => d [4] => e ) ) Array ( [0] => Array ( [2] => a [3] => b [4] => c [5] => d [6] => e ) ) Array ( [0] => Array ( [0] => a [1] => b [2] => c [3] => d [4] => e ) ) Array ( [0] => Array ( [2] => a [3] => b [4] => c [5] => d [6] => e ) ) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/array_combine.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/array_combine.phpt +++ pear/PHP_Compat/tests/function/array_combine.phpt --TEST-- Function -- array_combine --SKIPIF-- <?php if (function_exists('array_combine')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('array_combine'); $a = array('green', 'red', 'yellow'); $b = array('avocado', 'apple', 'banana'); $c = array_combine($a, $b); print_r($c); ?> --EXPECT-- Array ( [green] => avocado [red] => apple [yellow] => banana ) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/array_diff_assoc.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/array_diff_assoc.phpt +++ pear/PHP_Compat/tests/function/array_diff_assoc.phpt --TEST-- Function -- array_diff_assoc --SKIPIF-- <?php if (function_exists('array_diff_assoc')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('array_diff_assoc'); $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "green", "yellow", "red"); $result = array_diff_assoc($array1, $array2); print_r($result); ?> --EXPECT-- Array ( [b] => brown [c] => blue [0] => red ) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/array_udif_assoc.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/array_udif_assoc.phpt +++ pear/PHP_Compat/tests/function/array_udif_assoc.phpt --TEST-- Function -- array_udiff_assoc --SKIPIF-- <?php if (function_exists('array_udiff_assoc')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('array_udiff_assoc'); class cr { var $priv_member; function cr($val) { $this->priv_member = $val; } function comp_func_cr($a, $b) { if ($a->priv_member === $b->priv_member) return 0; return ($a->priv_member > $b->priv_member)? 1:-1; } } $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),); $result = array_udiff_assoc($a, $b, array("cr", "comp_func_cr")); echo serialize($result); ?> --EXPECT-- a:3:{s:3:"0.1";O:2:"cr":1:{s:11:"priv_member";i:9;}s:3:"0.5";O:2:"cr":1:{s:11:"priv_member";i:12;}i:0;O:2:"cr":1:{s:11:"priv_member";i:23;}} http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/array_udiff.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/array_udiff.phpt +++ pear/PHP_Compat/tests/function/array_udiff.phpt --TEST-- Function -- array_udiff --SKIPIF-- <?php if (function_exists('array_udiff')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('array_udiff'); class cr { var $priv_member; function cr($val) { $this->priv_member = $val; } function comp_func_cr($a, $b) { if ($a->priv_member === $b->priv_member) return 0; return ($a->priv_member > $b->priv_member)? 1:-1; } } $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),); $result = array_udiff($a, $b, array("cr", "comp_func_cr")); echo serialize($result); ?> --EXPECT-- a:2:{s:3:"0.5";O:2:"cr":1:{s:11:"priv_member";i:12;}i:0;O:2:"cr":1:{s:11:"priv_member";i:23;}} http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/file_get_contents.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/file_get_contents.phpt +++ pear/PHP_Compat/tests/function/file_get_contents.phpt --TEST-- Function -- file_get_contents --SKIPIF-- <?php if (function_exists('file_get_contents')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('file_get_contents'); $tmpfname = tempnam('/tmp', 'php'); $handle = fopen($tmpfname, 'w'); fwrite($handle, "test test"); fclose($handle); echo file_get_contents($tmpfname); unlink($tmpfname); ?> --EXPECT-- test test http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/file_put_contents.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/file_put_contents.phpt +++ pear/PHP_Compat/tests/function/file_put_contents.phpt --TEST-- Function -- file_put_contents --SKIPIF-- <?php if (function_exists('file_put_contents')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('file_put_contents'); // With a string $string = "abcd"; $tmpfname = tempnam('/tmp', 'php'); $res = file_put_contents($tmpfname, $string); $data = implode('', file($tmpfname)); unlink($tmpfname); echo $res, "\n"; echo $data, "\n"; // With an array $string = array('foo', 'bar'); $tmpfname = tempnam('/tmp', 'php'); $res = file_put_contents($tmpfname, $string); $data = implode('', file($tmpfname)); unlink($tmpfname); echo $res, "\n"; echo $data, "n"; // Test append $string = 'foobar'; $string2 = 'testtest'; $tmpfname = tempnam('/tmp', 'php'); echo file_put_contents($tmpfname, $string), "\n"; echo file_put_contents($tmpfname, $string2, FILE_APPEND), "\n"; echo implode('', file($tmpfname)), "\n"; echo file_put_contents($tmpfname, $string2), "\n"; echo implode('', file($tmpfname)); unlink($tmpfname); ?> --EXPECT-- 4 abcd 6 foobar 6 8 foobartesttest 8 testtest http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/fprintf.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/fprintf.phpt +++ pear/PHP_Compat/tests/function/fprintf.phpt --TEST-- Function -- fprintf --SKIPIF-- <?php if (function_exists('fprintf')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('fprintf'); $tmpfname = tempnam('/tmp', 'php'); $handle = fopen($tmpfname, 'w'); fprintf($handle, 'The %s went to the %s for %d days', 'dog', 'park', 2); fclose($handle); $data = implode('', file($tmpfname)); unlink($tmpfname); echo $data; ?> --EXPECT-- The dog went to the park for 2 days http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/html_entity_decode.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/html_entity_decode.phpt +++ pear/PHP_Compat/tests/function/html_entity_decode.phpt --TEST-- Function -- html_entity_decode --SKIPIF-- <?php if (function_exists('html_entity_decode')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('html_entity_decode'); $values = array (2, 'car'); $string = "I'll "walk" the <b>dog</b> now"; echo html_entity_decode($string); ?> --EXPECT-- I'll "walk" the <b>dog</b> now http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/http_build_query.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/http_build_query.phpt +++ pear/PHP_Compat/tests/function/http_build_query.phpt --TEST-- Function -- http_build_query --SKIPIF-- <?php if (function_exists('http_build_query')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('http_build_query'); // Simple $data = array('foo'=>'bar', 'baz'=>'boom', 'cow'=>'milk', 'php'=>'hypertext processor'); echo http_build_query($data), "\n"; // With an object class myClass { var $foo; var $baz; function myClass() { $this->foo = 'bar'; $this->baz = 'boom'; } } $data = new myClass(); echo http_build_query($data), "\n"; // With numerically indexed elements $data = array('foo', 'bar', 'baz', 'boom', 'cow' => 'milk', 'php' =>'hypertext processor'); echo http_build_query($data), "\n"; echo http_build_query($data, 'myvar_'), "\n"; // With a complex array $data = array('user'=>array('name'=>'Bob Smith', 'age'=>47, 'sex'=>'M', 'dob'=>'5/12/1956'), 'pastimes'=>array('golf', 'opera', 'poker', 'rap'), 'children'=>array('bobby'=>array('age'=>12, 'sex'=>'M'), 'sally'=>array('age'=>8, 'sex'=>'F')), 'CEO'); echo http_build_query($data, 'flags_'); ?> --EXPECT-- foo=bar&baz=boom&cow=milk&php=hypertext+processor foo=bar&baz=boom 0=foo&1=bar&2=baz&3=boom&cow=milk&php=hypertext+processor myvar_0=foo&myvar_1=bar&myvar_2=baz&myvar_3=boom&cow=milk&php=hypertext+processor user[name]=Bob+Smith&user[age]=47&user[sex]=M&user[dob]=5%2F12%2F1956&pastimes[0]=golf&pastimes[1]=opera&pastimes[2]=poker&pastimes[3]=rap&children[bobby][age]=12&children[bobby][sex]=M&children[sally][age]=8&children[sally][sex]=F&flags_0=CEO http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/is_a.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/is_a.phpt +++ pear/PHP_Compat/tests/function/is_a.phpt --TEST-- Function -- is_a --SKIPIF-- <?php if (function_exists('is_a')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('is_a'); class WidgetFactory { var $oink = 'moo'; } $wf = new WidgetFactory(); if (is_a($wf, 'WidgetFactory')) { echo 'true'; } ?> --EXPECT-- true http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/scandir.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/scandir.phpt +++ pear/PHP_Compat/tests/function/scandir.phpt --TEST-- Function -- scandir --SKIPIF-- <?php if (function_exists('scandir')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('scandir'); // Create a folder and fill it with files mkdir('tmp'); touch('tmp/test1'); touch('tmp/test2'); // Scan it $dir = 'tmp'; // Not sorted $files = scandir($dir); // Sorted $files2 = scandir($dir, 1); // List the results print_r($files); print_r($files2); // Remove the files unlink('tmp/test1'); unlink('tmp/test2'); rmdir('tmp'); ?> --EXPECT-- Array ( [0] => . [1] => .. [2] => test1 [3] => test2 ) Array ( [0] => test2 [1] => test1 [2] => .. [3] => . ) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/str_ireplace.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/str_ireplace.phpt +++ pear/PHP_Compat/tests/function/str_ireplace.phpt --TEST-- Function -- str_ireplace --SKIPIF-- <?php if (function_exists('str_ireplace')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('str_ireplace'); // // Simple // $search = '{object}'; $replace = 'fence'; $subject = 'The dog jumped over the {object}'; echo str_ireplace($search, $replace, $subject), "\n"; // // With subject as array // // As a full array $search = '{SUBJECT}'; $replace = 'Lady'; $subject = array('A {subject}', 'The {subject}', 'My {subject}'); print_r(str_ireplace($search, $replace, $subject)); // As a single array $search = '{SUBJECT}'; $replace = 'Lady'; $subject = array('The dog jumped over the {object}'); print_r(str_ireplace($search, $replace, $subject)); // // Search as string, replace as array // $search = '{object}'; $replace = array('cat', 'dog', 'tiger'); $subject = 'The dog jumped over the {object}'; // Supress the error, no way of knowing how it'll turn out on the users machine echo @str_ireplace($search, $replace, $subject), "\n"; // // Search as array, Replace as string // $search = array('{ANIMAL}', '{OBJECT}', '{THING}'); $replace = 'frog'; $subject = 'The {animal} jumped over the {object} and the {thing}...'; echo str_ireplace($search, $replace, $subject), "\n"; // // Search and Replace as arrays // // Simple $search = array('{ANIMAL}', '{OBJECT}'); $replace = array('frog', 'gate'); $subject = 'The {animal} jumped over the {object}'; echo str_ireplace($search, $replace, $subject), "\n"; // More in search $search = array('{ANIMAL}', '{OBJECT}', '{THING}'); $replace = array('frog', 'gate'); $subject = 'The {animal} jumped over the {object} and the {thing}...'; echo str_ireplace($search, $replace, $subject), "\n"; // More in replace $search = array('{ANIMAL}', '{OBJECT}'); $replace = array('frog', 'gate', 'door'); $subject = 'The {animal} jumped over the {object} and the {thing}...'; echo str_ireplace($search, $replace, $subject), "\n"; // // All arrays // $search = array('{ANIMAL}', '{OBJECT}', '{THING}'); $replace = array('frog', 'gate', 'beer'); $subject = array('A {animal}', 'The {object}', 'My {thing}'); print_r(str_ireplace($search, $replace, $subject)); ?> --EXPECT-- The dog jumped over the fence Array ( [0] => A Lady [1] => The Lady [2] => My Lady ) Array ( [0] => The dog jumped over the {object} ) The dog jumped over the Array The frog jumped over the frog and the frog... The frog jumped over the gate The frog jumped over the gate and the ... The frog jumped over the gate and the {thing}... Array ( [0] => A frog [1] => The gate [2] => My beer ) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/str_split.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/str_split.phpt +++ pear/PHP_Compat/tests/function/str_split.phpt --TEST-- Function -- str_split --SKIPIF-- <?php if (function_exists('str_split')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('str_split'); // Simple $str = "Hello Friend"; $arr = str_split($str); print_r($arr); // With a chunk size specified $str = "Hello Friend"; $arr = str_split($str, 3); print_r($arr); // With chunk size bigger than the string $str = "abcd"; $arr = str_split($str, 3); print_r($arr); // String that has a remainder less than the chunk size $str = "abcd"; $arr = str_split($str, 3); print_r($arr); ?> --EXPECT-- Array ( [0] => H [1] => e [2] => l [3] => l [4] => o [5] => [6] => F [7] => r [8] => i [9] => e [10] => n [11] => d ) Array ( [0] => Hel [1] => lo [2] => Fri [3] => end ) Array ( [0] => abc [1] => d ) Array ( [0] => abc [1] => d ) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/stripos.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/stripos.phpt +++ pear/PHP_Compat/tests/function/stripos.phpt --TEST-- Function -- stripos --SKIPIF-- <?php if (function_exists('stripos')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('stripos'); $haystack = 'Cat Dinner Dog Lion Mouse Sheep Wolf Cat Dog'; $needle = 'DOG'; // Simple var_dump(stripos($haystack, $needle)); // With offset var_dump(stripos($haystack, $needle, 4)); var_dump(stripos($haystack, $needle, 10)); var_dump(stripos($haystack, $needle, 15)); ?> --EXPECT-- int(11) int(11) int(11) int(41) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/strripos.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/strripos.phpt +++ pear/PHP_Compat/tests/function/strripos.phpt --TEST-- Function -- strripos --SKIPIF-- <?php if (function_exists('strripos')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('strripos'); // Simple $haystack = 'Cat Dog Lion Mouse Sheep Wolf Cat Dog'; $needle = 'DOG'; var_dump(strripos($haystack, $needle)); // With offset $haystack = 'Cat Dinner Dog Lion Mouse Sheep Wolf Cat Dog Donut'; $needle = 'DOG'; var_dump(strripos($haystack, $needle, 3)); var_dump(strripos($haystack, $needle, 30)); var_dump(strripos($haystack, $needle, 50)); var_dump(strripos($haystack, $needle, -1)); var_dump(strripos($haystack, $needle, -10)); var_dump(strripos($haystack, $needle, -30)); var_dump(strripos($haystack, $needle, -50)); ?> --EXPECT-- int(34) int(41) int(41) bool(false) int(41) int(11) int(11) bool(false) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/var_export.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/var_export.phpt +++ pear/PHP_Compat/tests/function/var_export.phpt --TEST-- Function -- var_export --SKIPIF-- <?php if (function_exists('var_export')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('var_export'); $a = array (1, 2, array ("a", "b", "c")); var_export($a); echo "\n"; echo var_export($a, true); ?> --EXPECT-- array ( 0 => 1, 1 => 2, 2 => array ( 0 => 'a', 1 => 'b', 2 => 'c', ), ) array ( 0 => 1, 1 => 2, 2 => array ( 0 => 'a', 1 => 'b', 2 => 'c', ), ) http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/vprintf.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/vprintf.phpt +++ pear/PHP_Compat/tests/function/vprintf.phpt --TEST-- Function -- vprintf --SKIPIF-- <?php if (function_exists('vprintf')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('vprintf'); $values = array (2, 'car'); $format = "There are %d monkeys in the %s"; vprintf($format, $values); ?> --EXPECT-- There are 2 monkeys in the car http://cvs.php.net/co.php/pear/PHP_Compat/tests/function/vsprintf.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/function/vsprintf.phpt +++ pear/PHP_Compat/tests/function/vsprintf.phpt --TEST-- Function -- vsprintf --SKIPIF-- <?php if (function_exists('vsprintf')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); PHP_Compat::loadFunction('vsprintf'); $values = array (2, 'car'); $format = "There are %d monkeys in the %s"; vprintf($format, $values); ?> --EXPECT-- There are 2 monkeys in the car http://cvs.php.net/co.php/pear/PHP_Compat/tests/loadconstant.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/loadconstant.phpt +++ pear/PHP_Compat/tests/loadconstant.phpt --TEST-- Method -- PHP_Compat::loadConstant -- load invalid and valid constants --SKIPIF-- <?php if (defined('E_STRICT')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); // Singular $res = PHP_Compat::loadConstant('invalid'); echo ($res === false) ? 'false' : 'true', "\n"; $res = PHP_Compat::loadConstant('E_STRICT'); echo ($res === false) ? 'false' : 'true'; // With an array $comps = array('invalid', 'also-invalid', 'more-invalid', 'E_STRICT'); $res = PHP_Compat::loadConstant($comps); foreach ($res as $value) { echo ($value === false) ? 'false' : 'true', "\n"; } ?> --EXPECT-- false true false false false true http://cvs.php.net/co.php/pear/PHP_Compat/tests/loadfunction.phpt?r=1.1&p=1 Index: pear/PHP_Compat/tests/loadfunction.phpt +++ pear/PHP_Compat/tests/loadfunction.phpt --TEST-- Method -- PHP_Compat::loadFunction -- load invalid and valid function --SKIPIF-- <?php if (function_exists('str_split')) { echo 'skip'; } ?> --FILE-- <?php require_once ('PHP/Compat.php'); // Singular $res = PHP_Compat::loadFunction('invalid'); echo ($res === false) ? 'false' : 'true', "\n"; $res = PHP_Compat::loadFunction('str_split'); echo ($res === false) ? 'false' : 'true'; // With an array $comps = array('invalid', 'also-invalid', 'more-invalid', 'str_split'); $res = PHP_Compat::loadFunction($comps); foreach ($res as $value) { echo ($value === false) ? 'false' : 'true', "\n"; } ?> --EXPECT-- false true false false false true