1--TEST--
2Test strspn() function : usage variations - with heredoc strings, varying mask & default start and len args
3--FILE--
4<?php
5/*
6* Testing strspn() : with heredoc string, varying mask and default start and len arguments
7*/
8
9echo "*** Testing strspn() : with different mask strings ***\n";
10
11// initialing required variables
12// defining different heredoc strings
13$empty_heredoc = <<<EOT
14EOT;
15
16$heredoc_with_newline = <<<EOT
17\n
18
19EOT;
20
21$heredoc_with_characters = <<<EOT
22first line of heredoc string
23second line of heredoc string
24third line of heredocstring
25EOT;
26
27$heredoc_with_newline_and_tabs = <<<EOT
28hello\tworld\nhello\nworld\n
29EOT;
30
31$heredoc_with_alphanumerics = <<<EOT
32hello123world456
331234hello\t1234
34EOT;
35
36$heredoc_with_embedded_nulls = <<<EOT
37hello\0world\0hello
38\0hello\0
39EOT;
40
41$heredoc_with_hexa_octal = <<<EOT
42hello\0\100\xaaworld\0hello
43\0hello\0
44EOT;
45
46// defining array of different heredoc strings
47$heredoc_strings = array(
48                   $empty_heredoc,
49                   $heredoc_with_newline,
50                   $heredoc_with_characters,
51                   $heredoc_with_newline_and_tabs,
52                   $heredoc_with_alphanumerics,
53                   $heredoc_with_embedded_nulls,
54                   $heredoc_with_hexa_octal
55                   );
56
57// defining array of different mask strings
58$mask_array = array(
59            "",
60            '',
61            "fh\ne\trlsti \l",
62            'fieh\n\trlsti \l',
63            "\t",
64            "lt\ ",
65            'l\t',
66            "fl\t\eh ",
67            "l \te",
68                    "lf\the\i\100\xaa"
69                   );
70
71
72// loop through each element of the array for different heredoc and mask strings
73
74$count = 1;
75
76foreach($heredoc_strings as $str)  {
77  echo "\n-- Iteration $count --\n";
78  foreach($mask_array as $mask)  {
79      var_dump( strspn($str,$mask) ); // with default start and len value
80  }
81  $count++;
82}
83
84echo "Done"
85?>
86--EXPECT--
87*** Testing strspn() : with different mask strings ***
88
89-- Iteration 1 --
90int(0)
91int(0)
92int(0)
93int(0)
94int(0)
95int(0)
96int(0)
97int(0)
98int(0)
99int(0)
100
101-- Iteration 2 --
102int(0)
103int(0)
104int(2)
105int(0)
106int(0)
107int(0)
108int(0)
109int(0)
110int(0)
111int(0)
112
113-- Iteration 3 --
114int(0)
115int(0)
116int(8)
117int(11)
118int(0)
119int(0)
120int(0)
121int(1)
122int(0)
123int(2)
124
125-- Iteration 4 --
126int(0)
127int(0)
128int(4)
129int(4)
130int(0)
131int(0)
132int(0)
133int(1)
134int(0)
135int(4)
136
137-- Iteration 5 --
138int(0)
139int(0)
140int(4)
141int(4)
142int(0)
143int(0)
144int(0)
145int(1)
146int(0)
147int(4)
148
149-- Iteration 6 --
150int(0)
151int(0)
152int(4)
153int(4)
154int(0)
155int(0)
156int(0)
157int(1)
158int(0)
159int(4)
160
161-- Iteration 7 --
162int(0)
163int(0)
164int(4)
165int(4)
166int(0)
167int(0)
168int(0)
169int(1)
170int(0)
171int(4)
172Done
173