import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-strings / strspn_variation5.php
blobd75e33a38a2b6650fd2cedde09ae998c2dfdb3ea
1 <?php
2 /* Prototype : proto int strspn(string str, string mask [, int start [, int len]])
3 * Description: Finds length of initial segment consisting entirely of characters found in mask.
4 If start or/and length is provided works like strspn(substr($s,$start,$len),$good_chars)
5 * Source code: ext/standard/string.c
6 * Alias to functions: none
7 */
9 /*
10 * Testing strspn() : with different heredoc strings as str argument
13 echo "*** Testing strspn() : with heredoc strings ***\n";
15 // initialing required variables
16 // defining different heredoc strings
17 $empty_heredoc = <<<EOT
18 EOT;
20 $heredoc_with_newline = <<<EOT
23 EOT;
25 $heredoc_with_characters = <<<EOT
26 first line of heredoc string
27 second line of heredoc string
28 third line of heredocstring
29 EOT;
31 $heredoc_with_newline_and_tabs = <<<EOT
32 hello\tworld\nhello\nworld\n
33 EOT;
35 $heredoc_with_alphanumerics = <<<EOT
36 hello123world456
37 1234hello\t1234
38 EOT;
40 $heredoc_with_embedded_nulls = <<<EOT
41 hello\0world\0hello
42 \0hello\0
43 EOT;
45 $heredoc_with_hexa_octal = <<<EOT
46 hello\0\100\xaaworld\0hello
47 \0hello\0
48 EOT;
50 $heredoc_strings = array(
51 $empty_heredoc,
52 $heredoc_with_newline,
53 $heredoc_with_characters,
54 $heredoc_with_newline_and_tabs,
55 $heredoc_with_alphanumerics,
56 $heredoc_with_embedded_nulls,
57 $heredoc_with_hexa_octal
60 $mask = "sfth12\ne34l567890\0\xaa\100o";
63 // loop through each element of the array for str argument
65 foreach($heredoc_strings as $str) {
66 echo "\n-- Iteration with str value as \"$str\" --\n";
67 var_dump( strspn($str,$mask) ); // with default start and len values
70 echo "Done"