????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.28 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/b8009/php-5.6.22/ext/standard/tests/strings/ |
Upload File : |
--TEST--
Test strrchr() function : usage variations - double quoted strings
--FILE--
<?php
/* Prototype : string strrchr(string $haystack, string $needle);
* Description: Finds the last occurrence of a character in a string.
* Source code: ext/standard/string.c
*/
/* Test strrchr() function by passing various double quoted strings for 'haystack' & 'needle' */
echo "*** Testing strrchr() function: with various double quoted strings ***";
$haystack = "Hello,\t\n\0\n $&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 ";
$needle = array(
//regular strings
"l",
"L",
"HELLO",
"hEllo",
//escape characters
"\t",
"\T",
" ",
"\n",
"\N",
"
", //new line
//nulls
"\0",
NULL,
null,
//boolean false
FALSE,
false,
//empty string
"",
//special chars
" ",
"$",
" $",
"&",
"!#",
"%\o",
"\o,",
"()",
"*+",
"+",
"-",
".",
".;",
":;",
";",
"<=>",
">",
"=>",
"?",
"@",
"@hEllo",
"12345", //decimal numeric string
"\x23", //hexadecimal numeric string
"#", //respective ASCII char of \x23
"\101", //octal numeric string
"A", //respective ASCII char of \101
"456HEE", //numerics + chars
42, //needle as int(ASCII value of "*")
$haystack //haystack as needle
);
/* loop through to get the position of the needle in haystack string */
$count = 1;
for($index=0; $index<count($needle); $index++) {
echo "\n-- Iteration $count --\n";
var_dump( strrchr($haystack, $needle[$index]) );
$count++;
}
echo "*** Done ***";
?>
--EXPECTF--
*** Testing strrchr() function: with various double quoted strings ***
-- Iteration 1 --
string(16) "lo123456he #4 A "
-- Iteration 2 --
bool(false)
-- Iteration 3 --
string(53) "Hello,
$&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
-- Iteration 4 --
string(8) "he #4 A "
-- Iteration 5 --
string(47) "
$&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
-- Iteration 6 --
string(36) "\o,()*+-./:;<=>?@hello123456he #4 A "
-- Iteration 7 --
string(47) "
$&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
-- Iteration 8 --
string(44) "
$&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
-- Iteration 9 --
string(36) "\o,()*+-./:;<=>?@hello123456he #4 A "
-- Iteration 10 --
string(44) "
$&!#%\o,()*+-./:;<=>?@hello123456he #4 A "
-- Iteration 11 --
string(45) "