2002-10-06 19:12:22 +00:00
|
|
|
|
--TEST--
|
New version of addcslashes.phpt, md5_file.phpt, str_replace.phpt, substr.phpt, chr_ord.phpt, strpos.phpt, strstr.phpt, trim1.phpt, implode1.phpt, str_repeat.phpt, substr_count.phpt
2007-05-12 10:15:02 +00:00
|
|
|
|
Test chr() and ord() functions
|
2002-10-06 19:12:22 +00:00
|
|
|
|
--FILE--
|
|
|
|
|
<?php
|
New version of addcslashes.phpt, md5_file.phpt, str_replace.phpt, substr.phpt, chr_ord.phpt, strpos.phpt, strstr.phpt, trim1.phpt, implode1.phpt, str_repeat.phpt, substr_count.phpt
2007-05-12 10:15:02 +00:00
|
|
|
|
/* Prototype: string chr ( int $ascii );
|
|
|
|
|
Description: Returns a one-character string containing the character specified by ascii.
|
|
|
|
|
|
|
|
|
|
Prototype: int ord ( string $string );
|
|
|
|
|
Description: Returns the ASCII value of the first character of string
|
|
|
|
|
*/
|
|
|
|
|
echo "*** Testing ord() & chr() basic operations ***\n";
|
2002-10-06 19:12:22 +00:00
|
|
|
|
for($i=0; $i<256; $i++) echo !ord(chr($i)) == $i;
|
New version of addcslashes.phpt, md5_file.phpt, str_replace.phpt, substr.phpt, chr_ord.phpt, strpos.phpt, strstr.phpt, trim1.phpt, implode1.phpt, str_repeat.phpt, substr_count.phpt
2007-05-12 10:15:02 +00:00
|
|
|
|
|
|
|
|
|
/* miscelleous input */
|
|
|
|
|
echo "\n*** Testing chr() usage variations ***\n";
|
|
|
|
|
$arr_test = array(
|
|
|
|
|
"true",
|
|
|
|
|
"false",
|
|
|
|
|
true,
|
|
|
|
|
false,
|
|
|
|
|
"",
|
|
|
|
|
" ",
|
|
|
|
|
"a",
|
|
|
|
|
299,
|
|
|
|
|
321,
|
|
|
|
|
NULL,
|
|
|
|
|
'\0',
|
|
|
|
|
"0",
|
|
|
|
|
-312,
|
|
|
|
|
12.999,
|
|
|
|
|
-1.05009,
|
|
|
|
|
1100011,
|
|
|
|
|
"aaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccccdddddddddddddddddddddddddddddddddddddddddd",
|
|
|
|
|
"abcd\nabcd\tabcd\0abcd\rabcdNULLabcdefgh",
|
|
|
|
|
"abcd\x00abcd\x00abcd\x00abcdefghij",
|
|
|
|
|
);
|
|
|
|
|
$counter=1;
|
|
|
|
|
foreach($arr_test as $var){
|
|
|
|
|
echo "-- Iteration $counter --\n";
|
|
|
|
|
var_dump( chr($var) );
|
|
|
|
|
$counter++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo "\n*** Testing ord() usage variations ***\n";
|
|
|
|
|
$counter=1;
|
|
|
|
|
foreach($arr_test as $var){
|
|
|
|
|
echo "-- Iteration $counter --\n";
|
|
|
|
|
var_dump( ord($var) );
|
|
|
|
|
$counter++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Error conditions */
|
|
|
|
|
echo "\n*** Testing chr() error conditions ***\n";
|
|
|
|
|
//zero arguments
|
|
|
|
|
var_dump( chr() );
|
|
|
|
|
// more than expected no. of args
|
|
|
|
|
var_dump( chr($arr_test[0], $arr_test[1]) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "\n*** Testing ord() error conditions ***\n";
|
|
|
|
|
// zero arguments
|
|
|
|
|
var_dump( ord() );
|
|
|
|
|
// more than expected no. of args
|
|
|
|
|
var_dump( ord($arr_test[0], $arr_test[1]) );
|
|
|
|
|
|
|
|
|
|
echo "Done\n";
|
2002-10-06 19:12:22 +00:00
|
|
|
|
?>
|
New version of addcslashes.phpt, md5_file.phpt, str_replace.phpt, substr.phpt, chr_ord.phpt, strpos.phpt, strstr.phpt, trim1.phpt, implode1.phpt, str_repeat.phpt, substr_count.phpt
2007-05-12 10:15:02 +00:00
|
|
|
|
--EXPECTF--
|
|
|
|
|
*** Testing ord() & chr() basic operations ***
|
|
|
|
|
|
|
|
|
|
*** Testing chr() usage variations ***
|
|
|
|
|
-- Iteration 1 --
|
|
|
|
|
string(1) " |