1--TEST--
2Test % operator : various numbers as strings
3--FILE--
4<?php
5
6$strVals = array(
7   "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
8   "a5.9"
9);
10
11error_reporting(E_ERROR);
12
13foreach ($strVals as $strVal) {
14   foreach($strVals as $otherVal) {
15	  echo "--- testing: '$strVal' % '$otherVal' ---\n";
16      try {
17        var_dump($strVal%$otherVal);
18      } catch (DivisionByZeroError $e) {
19        echo "Exception: " . $e->getMessage() . "\n";
20      }
21   }
22}
23
24
25?>
26===DONE===
27--EXPECT--
28--- testing: '0' % '0' ---
29Exception: Modulo by zero
30--- testing: '0' % '65' ---
31int(0)
32--- testing: '0' % '-44' ---
33int(0)
34--- testing: '0' % '1.2' ---
35int(0)
36--- testing: '0' % '-7.7' ---
37int(0)
38--- testing: '0' % 'abc' ---
39Exception: Modulo by zero
40--- testing: '0' % '123abc' ---
41int(0)
42--- testing: '0' % '123e5' ---
43int(0)
44--- testing: '0' % '123e5xyz' ---
45int(0)
46--- testing: '0' % ' 123abc' ---
47int(0)
48--- testing: '0' % '123 abc' ---
49int(0)
50--- testing: '0' % '123abc ' ---
51int(0)
52--- testing: '0' % '3.4a' ---
53int(0)
54--- testing: '0' % 'a5.9' ---
55Exception: Modulo by zero
56--- testing: '65' % '0' ---
57Exception: Modulo by zero
58--- testing: '65' % '65' ---
59int(0)
60--- testing: '65' % '-44' ---
61int(21)
62--- testing: '65' % '1.2' ---
63int(0)
64--- testing: '65' % '-7.7' ---
65int(2)
66--- testing: '65' % 'abc' ---
67Exception: Modulo by zero
68--- testing: '65' % '123abc' ---
69int(65)
70--- testing: '65' % '123e5' ---
71int(65)
72--- testing: '65' % '123e5xyz' ---
73int(65)
74--- testing: '65' % ' 123abc' ---
75int(65)
76--- testing: '65' % '123 abc' ---
77int(65)
78--- testing: '65' % '123abc ' ---
79int(65)
80--- testing: '65' % '3.4a' ---
81int(2)
82--- testing: '65' % 'a5.9' ---
83Exception: Modulo by zero
84--- testing: '-44' % '0' ---
85Exception: Modulo by zero
86--- testing: '-44' % '65' ---
87int(-44)
88--- testing: '-44' % '-44' ---
89int(0)
90--- testing: '-44' % '1.2' ---
91int(0)
92--- testing: '-44' % '-7.7' ---
93int(-2)
94--- testing: '-44' % 'abc' ---
95Exception: Modulo by zero
96--- testing: '-44' % '123abc' ---
97int(-44)
98--- testing: '-44' % '123e5' ---
99int(-44)
100--- testing: '-44' % '123e5xyz' ---
101int(-44)
102--- testing: '-44' % ' 123abc' ---
103int(-44)
104--- testing: '-44' % '123 abc' ---
105int(-44)
106--- testing: '-44' % '123abc ' ---
107int(-44)
108--- testing: '-44' % '3.4a' ---
109int(-2)
110--- testing: '-44' % 'a5.9' ---
111Exception: Modulo by zero
112--- testing: '1.2' % '0' ---
113Exception: Modulo by zero
114--- testing: '1.2' % '65' ---
115int(1)
116--- testing: '1.2' % '-44' ---
117int(1)
118--- testing: '1.2' % '1.2' ---
119int(0)
120--- testing: '1.2' % '-7.7' ---
121int(1)
122--- testing: '1.2' % 'abc' ---
123Exception: Modulo by zero
124--- testing: '1.2' % '123abc' ---
125int(1)
126--- testing: '1.2' % '123e5' ---
127int(1)
128--- testing: '1.2' % '123e5xyz' ---
129int(1)
130--- testing: '1.2' % ' 123abc' ---
131int(1)
132--- testing: '1.2' % '123 abc' ---
133int(1)
134--- testing: '1.2' % '123abc ' ---
135int(1)
136--- testing: '1.2' % '3.4a' ---
137int(1)
138--- testing: '1.2' % 'a5.9' ---
139Exception: Modulo by zero
140--- testing: '-7.7' % '0' ---
141Exception: Modulo by zero
142--- testing: '-7.7' % '65' ---
143int(-7)
144--- testing: '-7.7' % '-44' ---
145int(-7)
146--- testing: '-7.7' % '1.2' ---
147int(0)
148--- testing: '-7.7' % '-7.7' ---
149int(0)
150--- testing: '-7.7' % 'abc' ---
151Exception: Modulo by zero
152--- testing: '-7.7' % '123abc' ---
153int(-7)
154--- testing: '-7.7' % '123e5' ---
155int(-7)
156--- testing: '-7.7' % '123e5xyz' ---
157int(-7)
158--- testing: '-7.7' % ' 123abc' ---
159int(-7)
160--- testing: '-7.7' % '123 abc' ---
161int(-7)
162--- testing: '-7.7' % '123abc ' ---
163int(-7)
164--- testing: '-7.7' % '3.4a' ---
165int(-1)
166--- testing: '-7.7' % 'a5.9' ---
167Exception: Modulo by zero
168--- testing: 'abc' % '0' ---
169Exception: Modulo by zero
170--- testing: 'abc' % '65' ---
171int(0)
172--- testing: 'abc' % '-44' ---
173int(0)
174--- testing: 'abc' % '1.2' ---
175int(0)
176--- testing: 'abc' % '-7.7' ---
177int(0)
178--- testing: 'abc' % 'abc' ---
179Exception: Modulo by zero
180--- testing: 'abc' % '123abc' ---
181int(0)
182--- testing: 'abc' % '123e5' ---
183int(0)
184--- testing: 'abc' % '123e5xyz' ---
185int(0)
186--- testing: 'abc' % ' 123abc' ---
187int(0)
188--- testing: 'abc' % '123 abc' ---
189int(0)
190--- testing: 'abc' % '123abc ' ---
191int(0)
192--- testing: 'abc' % '3.4a' ---
193int(0)
194--- testing: 'abc' % 'a5.9' ---
195Exception: Modulo by zero
196--- testing: '123abc' % '0' ---
197Exception: Modulo by zero
198--- testing: '123abc' % '65' ---
199int(58)
200--- testing: '123abc' % '-44' ---
201int(35)
202--- testing: '123abc' % '1.2' ---
203int(0)
204--- testing: '123abc' % '-7.7' ---
205int(4)
206--- testing: '123abc' % 'abc' ---
207Exception: Modulo by zero
208--- testing: '123abc' % '123abc' ---
209int(0)
210--- testing: '123abc' % '123e5' ---
211int(123)
212--- testing: '123abc' % '123e5xyz' ---
213int(123)
214--- testing: '123abc' % ' 123abc' ---
215int(0)
216--- testing: '123abc' % '123 abc' ---
217int(0)
218--- testing: '123abc' % '123abc ' ---
219int(0)
220--- testing: '123abc' % '3.4a' ---
221int(0)
222--- testing: '123abc' % 'a5.9' ---
223Exception: Modulo by zero
224--- testing: '123e5' % '0' ---
225Exception: Modulo by zero
226--- testing: '123e5' % '65' ---
227int(50)
228--- testing: '123e5' % '-44' ---
229int(20)
230--- testing: '123e5' % '1.2' ---
231int(0)
232--- testing: '123e5' % '-7.7' ---
233int(6)
234--- testing: '123e5' % 'abc' ---
235Exception: Modulo by zero
236--- testing: '123e5' % '123abc' ---
237int(0)
238--- testing: '123e5' % '123e5' ---
239int(0)
240--- testing: '123e5' % '123e5xyz' ---
241int(0)
242--- testing: '123e5' % ' 123abc' ---
243int(0)
244--- testing: '123e5' % '123 abc' ---
245int(0)
246--- testing: '123e5' % '123abc ' ---
247int(0)
248--- testing: '123e5' % '3.4a' ---
249int(0)
250--- testing: '123e5' % 'a5.9' ---
251Exception: Modulo by zero
252--- testing: '123e5xyz' % '0' ---
253Exception: Modulo by zero
254--- testing: '123e5xyz' % '65' ---
255int(50)
256--- testing: '123e5xyz' % '-44' ---
257int(20)
258--- testing: '123e5xyz' % '1.2' ---
259int(0)
260--- testing: '123e5xyz' % '-7.7' ---
261int(6)
262--- testing: '123e5xyz' % 'abc' ---
263Exception: Modulo by zero
264--- testing: '123e5xyz' % '123abc' ---
265int(0)
266--- testing: '123e5xyz' % '123e5' ---
267int(0)
268--- testing: '123e5xyz' % '123e5xyz' ---
269int(0)
270--- testing: '123e5xyz' % ' 123abc' ---
271int(0)
272--- testing: '123e5xyz' % '123 abc' ---
273int(0)
274--- testing: '123e5xyz' % '123abc ' ---
275int(0)
276--- testing: '123e5xyz' % '3.4a' ---
277int(0)
278--- testing: '123e5xyz' % 'a5.9' ---
279Exception: Modulo by zero
280--- testing: ' 123abc' % '0' ---
281Exception: Modulo by zero
282--- testing: ' 123abc' % '65' ---
283int(58)
284--- testing: ' 123abc' % '-44' ---
285int(35)
286--- testing: ' 123abc' % '1.2' ---
287int(0)
288--- testing: ' 123abc' % '-7.7' ---
289int(4)
290--- testing: ' 123abc' % 'abc' ---
291Exception: Modulo by zero
292--- testing: ' 123abc' % '123abc' ---
293int(0)
294--- testing: ' 123abc' % '123e5' ---
295int(123)
296--- testing: ' 123abc' % '123e5xyz' ---
297int(123)
298--- testing: ' 123abc' % ' 123abc' ---
299int(0)
300--- testing: ' 123abc' % '123 abc' ---
301int(0)
302--- testing: ' 123abc' % '123abc ' ---
303int(0)
304--- testing: ' 123abc' % '3.4a' ---
305int(0)
306--- testing: ' 123abc' % 'a5.9' ---
307Exception: Modulo by zero
308--- testing: '123 abc' % '0' ---
309Exception: Modulo by zero
310--- testing: '123 abc' % '65' ---
311int(58)
312--- testing: '123 abc' % '-44' ---
313int(35)
314--- testing: '123 abc' % '1.2' ---
315int(0)
316--- testing: '123 abc' % '-7.7' ---
317int(4)
318--- testing: '123 abc' % 'abc' ---
319Exception: Modulo by zero
320--- testing: '123 abc' % '123abc' ---
321int(0)
322--- testing: '123 abc' % '123e5' ---
323int(123)
324--- testing: '123 abc' % '123e5xyz' ---
325int(123)
326--- testing: '123 abc' % ' 123abc' ---
327int(0)
328--- testing: '123 abc' % '123 abc' ---
329int(0)
330--- testing: '123 abc' % '123abc ' ---
331int(0)
332--- testing: '123 abc' % '3.4a' ---
333int(0)
334--- testing: '123 abc' % 'a5.9' ---
335Exception: Modulo by zero
336--- testing: '123abc ' % '0' ---
337Exception: Modulo by zero
338--- testing: '123abc ' % '65' ---
339int(58)
340--- testing: '123abc ' % '-44' ---
341int(35)
342--- testing: '123abc ' % '1.2' ---
343int(0)
344--- testing: '123abc ' % '-7.7' ---
345int(4)
346--- testing: '123abc ' % 'abc' ---
347Exception: Modulo by zero
348--- testing: '123abc ' % '123abc' ---
349int(0)
350--- testing: '123abc ' % '123e5' ---
351int(123)
352--- testing: '123abc ' % '123e5xyz' ---
353int(123)
354--- testing: '123abc ' % ' 123abc' ---
355int(0)
356--- testing: '123abc ' % '123 abc' ---
357int(0)
358--- testing: '123abc ' % '123abc ' ---
359int(0)
360--- testing: '123abc ' % '3.4a' ---
361int(0)
362--- testing: '123abc ' % 'a5.9' ---
363Exception: Modulo by zero
364--- testing: '3.4a' % '0' ---
365Exception: Modulo by zero
366--- testing: '3.4a' % '65' ---
367int(3)
368--- testing: '3.4a' % '-44' ---
369int(3)
370--- testing: '3.4a' % '1.2' ---
371int(0)
372--- testing: '3.4a' % '-7.7' ---
373int(3)
374--- testing: '3.4a' % 'abc' ---
375Exception: Modulo by zero
376--- testing: '3.4a' % '123abc' ---
377int(3)
378--- testing: '3.4a' % '123e5' ---
379int(3)
380--- testing: '3.4a' % '123e5xyz' ---
381int(3)
382--- testing: '3.4a' % ' 123abc' ---
383int(3)
384--- testing: '3.4a' % '123 abc' ---
385int(3)
386--- testing: '3.4a' % '123abc ' ---
387int(3)
388--- testing: '3.4a' % '3.4a' ---
389int(0)
390--- testing: '3.4a' % 'a5.9' ---
391Exception: Modulo by zero
392--- testing: 'a5.9' % '0' ---
393Exception: Modulo by zero
394--- testing: 'a5.9' % '65' ---
395int(0)
396--- testing: 'a5.9' % '-44' ---
397int(0)
398--- testing: 'a5.9' % '1.2' ---
399int(0)
400--- testing: 'a5.9' % '-7.7' ---
401int(0)
402--- testing: 'a5.9' % 'abc' ---
403Exception: Modulo by zero
404--- testing: 'a5.9' % '123abc' ---
405int(0)
406--- testing: 'a5.9' % '123e5' ---
407int(0)
408--- testing: 'a5.9' % '123e5xyz' ---
409int(0)
410--- testing: 'a5.9' % ' 123abc' ---
411int(0)
412--- testing: 'a5.9' % '123 abc' ---
413int(0)
414--- testing: 'a5.9' % '123abc ' ---
415int(0)
416--- testing: 'a5.9' % '3.4a' ---
417int(0)
418--- testing: 'a5.9' % 'a5.9' ---
419Exception: Modulo by zero
420===DONE===
421