import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-strings / strspn_variation7.php
blob005d4275ddab3f4668a346e441d914faee38d00a
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 heredoc string, varying start and default len arguments
13 echo "*** Testing strspn() : with different start values ***\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 // defining array of different heredoc strings
51 $heredoc_strings = array(
52 $empty_heredoc,
53 $heredoc_with_newline,
54 $heredoc_with_characters,
55 $heredoc_with_newline_and_tabs,
56 $heredoc_with_alphanumerics,
57 $heredoc_with_embedded_nulls,
58 $heredoc_with_hexa_octal
61 // defining array of different mask strings
62 $mask_array = array(
63 "",
64 '',
65 "f\nh\trstie \l",
66 'f\n\thrstei \l',
67 "\t",
68 "t\ e",
69 '\t',
70 "f\te\h ",
71 " \t",
72 "f\t\ih\100e\xa"
75 // defining array of different start values
76 $start_array = array(
80 -1,
81 -2,
82 2147483647, // max positive integer
83 -2147483648, // min negative integer
87 // loop through each element of the array for heredoc strings, mask strings and start values
89 $count = 1;
91 foreach($heredoc_strings as $str) {
92 echo "\n-- Iteration $count --\n";
93 foreach($mask_array as $mask) {
94 foreach($start_array as $start) {
95 var_dump( strspn($str,$mask,$start) ); // with default len value
98 $count++;
101 echo "Done"